本文整理汇总了Python中theano.tensor.signal.pool.pool_3d方法的典型用法代码示例。如果您正苦于以下问题:Python pool.pool_3d方法的具体用法?Python pool.pool_3d怎么用?Python pool.pool_3d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theano.tensor.signal.pool
的用法示例。
在下文中一共展示了pool.pool_3d方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pool3d
# 需要导入模块: from theano.tensor.signal import pool [as 别名]
# 或者: from theano.tensor.signal.pool import pool_3d [as 别名]
def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid',
data_format=None, pool_mode='max'):
data_format = normalize_data_format(data_format)
if padding == 'same':
w_pad = pool_size[0] - 2 if pool_size[0] % 2 == 1 else pool_size[0] - 1
h_pad = pool_size[1] - 2 if pool_size[1] % 2 == 1 else pool_size[1] - 1
d_pad = pool_size[2] - 2 if pool_size[2] % 2 == 1 else pool_size[2] - 1
pad = (w_pad, h_pad, d_pad)
elif padding == 'valid':
pad = (0, 0, 0)
else:
raise ValueError('Invalid padding:', padding)
if data_format == 'channels_last':
x = x.dimshuffle((0, 4, 1, 2, 3))
if pool_mode == 'max':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=pad,
mode='max')
elif pool_mode == 'avg':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=pad,
mode='average_exc_pad')
else:
raise ValueError('Invalid pooling mode:', pool_mode)
if padding == 'same':
expected_width = (x.shape[2] + strides[0] - 1) // strides[0]
expected_height = (x.shape[3] + strides[1] - 1) // strides[1]
expected_depth = (x.shape[4] + strides[2] - 1) // strides[2]
pool_out = pool_out[:, :,
: expected_width,
: expected_height,
: expected_depth]
if data_format == 'channels_last':
pool_out = pool_out.dimshuffle((0, 2, 3, 4, 1))
return pool_out
示例2: pool3d
# 需要导入模块: from theano.tensor.signal import pool [as 别名]
# 或者: from theano.tensor.signal.pool import pool_3d [as 别名]
def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid',
data_format=None, pool_mode='max'):
if data_format is None:
data_format = image_data_format()
if data_format not in {'channels_first', 'channels_last'}:
raise ValueError('Unknown data_format:', data_format)
if padding == 'same':
w_pad = pool_size[0] - 2 if pool_size[0] % 2 == 1 else pool_size[0] - 1
h_pad = pool_size[1] - 2 if pool_size[1] % 2 == 1 else pool_size[1] - 1
d_pad = pool_size[2] - 2 if pool_size[2] % 2 == 1 else pool_size[2] - 1
pad = (w_pad, h_pad, d_pad)
elif padding == 'valid':
pad = (0, 0, 0)
else:
raise ValueError('Invalid padding:', padding)
if data_format == 'channels_last':
x = x.dimshuffle((0, 4, 1, 2, 3))
if pool_mode == 'max':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=pad,
mode='max')
elif pool_mode == 'avg':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=pad,
mode='average_exc_pad')
else:
raise ValueError('Invalid pooling mode:', pool_mode)
if padding == 'same':
expected_width = (x.shape[2] + strides[0] - 1) // strides[0]
expected_height = (x.shape[3] + strides[1] - 1) // strides[1]
expected_depth = (x.shape[4] + strides[2] - 1) // strides[2]
pool_out = pool_out[:, :,
: expected_width,
: expected_height,
: expected_depth]
if data_format == 'channels_last':
pool_out = pool_out.dimshuffle((0, 2, 3, 4, 1))
return pool_out
示例3: pool3d
# 需要导入模块: from theano.tensor.signal import pool [as 别名]
# 或者: from theano.tensor.signal.pool import pool_3d [as 别名]
def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid',
data_format=None, pool_mode='max'):
if data_format is None:
data_format = image_data_format()
if data_format not in {'channels_first', 'channels_last'}:
raise ValueError('Unknown data_format:', data_format)
if padding == 'same':
w_pad = pool_size[0] - 2 if pool_size[0] % 2 == 1 else pool_size[0] - 1
h_pad = pool_size[1] - 2 if pool_size[1] % 2 == 1 else pool_size[1] - 1
d_pad = pool_size[2] - 2 if pool_size[2] % 2 == 1 else pool_size[2] - 1
padding = (w_pad, h_pad, d_pad)
elif padding == 'valid':
padding = (0, 0, 0)
else:
raise ValueError('Invalid padding:', padding)
if data_format == 'channels_last':
x = x.dimshuffle((0, 4, 1, 2, 3))
if pool_mode == 'max':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=padding,
mode='max')
elif pool_mode == 'avg':
pool_out = pool.pool_3d(x, ws=pool_size, stride=strides,
ignore_border=True,
pad=padding,
mode='average_exc_pad')
else:
raise ValueError('Invalid pooling mode:', pool_mode)
if padding == 'same':
expected_width = (x.shape[2] + strides[0] - 1) // strides[0]
expected_height = (x.shape[3] + strides[1] - 1) // strides[1]
expected_depth = (x.shape[4] + strides[2] - 1) // strides[2]
pool_out = pool_out[:, :,
: expected_width,
: expected_height,
: expected_depth]
if data_format == 'channels_last':
pool_out = pool_out.dimshuffle((0, 2, 3, 4, 1))
return pool_out