本文整理匯總了Python中cntk.MAX_POOLING屬性的典型用法代碼示例。如果您正苦於以下問題:Python cntk.MAX_POOLING屬性的具體用法?Python cntk.MAX_POOLING怎麽用?Python cntk.MAX_POOLING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cntk
的用法示例。
在下文中一共展示了cntk.MAX_POOLING屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_fast_rcnn_predictor
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [as 別名]
def create_fast_rcnn_predictor(conv_out, rois, fc_layers):
# RCNN
roi_out = roipooling(conv_out, rois, cntk.MAX_POOLING, (roi_dim, roi_dim), spatial_scale=1/16.0)
fc_out = fc_layers(roi_out)
# prediction head
W_pred = parameter(shape=(4096, globalvars['num_classes']), init=normal(scale=0.01), name="cls_score.W")
b_pred = parameter(shape=globalvars['num_classes'], init=0, name="cls_score.b")
cls_score = plus(times(fc_out, W_pred), b_pred, name='cls_score')
# regression head
W_regr = parameter(shape=(4096, globalvars['num_classes']*4), init=normal(scale=0.001), name="bbox_regr.W")
b_regr = parameter(shape=globalvars['num_classes']*4, init=0, name="bbox_regr.b")
bbox_pred = plus(times(fc_out, W_regr), b_regr, name='bbox_regr')
return cls_score, bbox_pred
# Please keep in sync with Readme.md
# Defines the Faster R-CNN network model for detecting objects in images
示例2: pool2d
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [as 別名]
def pool2d(x, pool_size, strides=(1, 1),
padding='valid', data_format=None,
pool_mode='max'):
data_format = normalize_data_format(data_format)
padding = _preprocess_border_mode(padding)
strides = strides
pool_size = pool_size
x = _preprocess_conv2d_input(x, data_format)
if pool_mode == 'max':
x = C.pooling(
x,
C.MAX_POOLING,
pool_size,
strides,
auto_padding=[padding])
elif pool_mode == 'avg':
x = C.pooling(
x,
C.AVG_POOLING,
pool_size,
strides,
auto_padding=[padding])
else:
raise ValueError('Invalid pooling mode: ' + str(pool_mode))
return _postprocess_conv2d_output(x, data_format)
示例3: pool3d
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [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)
padding = _preprocess_border_mode(padding)
x = _preprocess_conv3d_input(x, data_format)
if pool_mode == 'max':
x = C.pooling(
x,
C.MAX_POOLING,
pool_size,
strides,
auto_padding=[padding])
elif pool_mode == 'avg':
x = C.pooling(
x,
C.AVG_POOLING,
pool_size,
strides,
auto_padding=[padding])
else:
raise ValueError('Invalid pooling mode: ' + str(pool_mode))
return _postprocess_conv3d_output(x, data_format)
示例4: emit_Pool
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [as 別名]
def emit_Pool(self, IR_node):
input_node = self.IR_graph.get_node(IR_node.in_edges[0]).real_variable_name
if IR_node.layer.attr['global_pooling'].b:
self.used_layers.add('GlobalPooling')
code = "{:<15} = global_pooling({}, '{}', name = '{}')".format(
IR_node.variable_name,
input_node,
IR_node.get_attr('pooling_type'),
IR_node.name)
else:
for e in IR_node.get_attr('dilations', []):
assert e == 1
dim = len(IR_node.get_attr('kernel_shape')) - 2
padding = not self.is_valid_padding(IR_node.get_attr('auto_pad'), IR_node.get_attr('pads'))
padding = [False] + [padding] * dim
ceil_out_dim = self.is_ceil_mode(IR_node.get_attr('pads'))
pooling_type = IR_node.get_attr('pooling_type')
if pooling_type == 'MAX':
pooling_type = cntk.MAX_POOLING
elif pooling_type == 'AVG':
pooling_type = cntk.AVG_POOLING
else:
raise ValueError
if self.weight_loaded:
self.used_layers.add(IR_node.type)
code = "{:<15} = pooling({}, pooling_type={}, pooling_window_shape={}, strides={}, auto_padding={}, ceil_out_dim={})".format(
IR_node.variable_name,
input_node,
pooling_type,
tuple(IR_node.get_attr('kernel_shape')[1:-1]),
tuple(IR_node.get_attr('strides')[1:-1]),
padding,
ceil_out_dim
)
else:
raise NotImplementedError
return code
示例5: rename_Pooling
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [as 別名]
def rename_Pooling(self, source_node):
IR_node = self._convert_identity_operation(source_node, new_op='Pool')
dim = len(IR_node.attr['_output_shapes'].list.shape[0].dim)
kwargs = {}
# strides
kwargs['strides'] = list(source_node.get_attr('strides')) + [1]
if len(kwargs['strides']) < dim:
kwargs['strides'] = [1] + kwargs['strides']
# window_shape
kwargs['kernel_shape'] = list(source_node.get_attr('poolingWindowShape')) + [1]
if len(kwargs['kernel_shape']) < dim:
kwargs['kernel_shape'] = [1] + kwargs['kernel_shape']
# pool type
pool_type = source_node.get_attr('poolingType')
if pool_type == _cntk.MAX_POOLING:
kwargs['pooling_type'] = 'MAX'
elif pool_type == _cntk.AVG_POOLING:
kwargs['pooling_type'] = 'AVG'
else:
raise ValueError("Unknown pooling type [{}].".format(pool_type))
# padding
padding = source_node.get_attr('autoPadding')
if len(padding) >= dim - 1:
padding = padding[1:]
elif len(padding) < dim - 2:
padding.extend([padding[-1]] * (dim - len(padding) - 2))
for pad in padding:
assert pad == padding[-1]
kwargs['auto_pad'] = 'SAME_LOWER' if padding[0] else 'VALID'
kwargs['pads'] = self._convert_padding_to_IR(kwargs['kernel_shape'][1:-1], padding)
assign_IRnode_values(IR_node, kwargs)
示例6: pool2d
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [as 別名]
def pool2d(x, pool_size, strides=(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 ' + str(data_format))
padding = _preprocess_border_mode(padding)
strides = strides
pool_size = pool_size
x = _preprocess_conv2d_input(x, data_format)
if pool_mode == 'max':
x = C.pooling(
x,
C.MAX_POOLING,
pool_size,
strides,
auto_padding=[padding])
elif pool_mode == 'avg':
x = C.pooling(
x,
C.AVG_POOLING,
pool_size,
strides,
auto_padding=[padding])
else:
raise ValueError('Invalid pooling mode: ' + str(pool_mode))
return _postprocess_conv2d_output(x, data_format)
示例7: pool3d
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import MAX_POOLING [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 ' + str(data_format))
padding = _preprocess_border_mode(padding)
x = _preprocess_conv3d_input(x, data_format)
if pool_mode == 'max':
x = C.pooling(
x,
C.MAX_POOLING,
pool_size,
strides,
auto_padding=[padding])
elif pool_mode == 'avg':
x = C.pooling(
x,
C.AVG_POOLING,
pool_size,
strides,
auto_padding=[padding])
else:
raise ValueError('Invalid pooling mode: ' + str(pool_mode))
return _postprocess_conv3d_output(x, data_format)