本文整理匯總了Python中blocks.bricks.conv.MaxPooling.apply方法的典型用法代碼示例。如果您正苦於以下問題:Python MaxPooling.apply方法的具體用法?Python MaxPooling.apply怎麽用?Python MaxPooling.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類blocks.bricks.conv.MaxPooling
的用法示例。
在下文中一共展示了MaxPooling.apply方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_max_pooling
# 需要導入模塊: from blocks.bricks.conv import MaxPooling [as 別名]
# 或者: from blocks.bricks.conv.MaxPooling import apply [as 別名]
def test_max_pooling():
x = tensor.tensor4("x")
num_channels = 4
batch_size = 5
x_size = 17
y_size = 13
pool_size = 3
pool = MaxPooling((pool_size, pool_size))
y = pool.apply(x)
func = function([x], y)
x_val = numpy.ones((batch_size, num_channels, x_size, y_size), dtype=theano.config.floatX)
assert_allclose(func(x_val), numpy.ones((batch_size, num_channels, x_size / pool_size, y_size / pool_size)))
pool.input_dim = (x_size, y_size)
pool.get_dim("output") == (num_channels, x_size / pool_size + 1, y_size / pool_size + 1)
示例2: test_max_pooling_padding
# 需要導入模塊: from blocks.bricks.conv import MaxPooling [as 別名]
# 或者: from blocks.bricks.conv.MaxPooling import apply [as 別名]
def test_max_pooling_padding():
x = tensor.tensor4("x")
brick = MaxPooling((6, 2), padding=(3, 1), ignore_border=True)
y = brick.apply(x)
out = y.eval({x: numpy.zeros((2, 3, 6, 10), dtype=theano.config.floatX)})
assert out.shape == (2, 3, 2, 6)
示例3: test_max_pooling_ignore_border_false
# 需要導入模塊: from blocks.bricks.conv import MaxPooling [as 別名]
# 或者: from blocks.bricks.conv.MaxPooling import apply [as 別名]
def test_max_pooling_ignore_border_false():
x = tensor.tensor4("x")
brick = MaxPooling((5, 7), ignore_border=False)
y = brick.apply(x)
out = y.eval({x: numpy.zeros((4, 6, 12, 15), dtype=theano.config.floatX)})
assert out.shape == (4, 6, 3, 3)
示例4: test_max_pooling_ignore_border_true
# 需要導入模塊: from blocks.bricks.conv import MaxPooling [as 別名]
# 或者: from blocks.bricks.conv.MaxPooling import apply [as 別名]
def test_max_pooling_ignore_border_true():
x = tensor.tensor4("x")
brick = MaxPooling((3, 4), ignore_border=True)
y = brick.apply(x)
out = y.eval({x: numpy.zeros((8, 3, 10, 13), dtype=theano.config.floatX)})
assert out.shape == (8, 3, 3, 3)
示例5: Convolutional
# 需要導入模塊: from blocks.bricks.conv import MaxPooling [as 別名]
# 或者: from blocks.bricks.conv.MaxPooling import apply [as 別名]
# Convolution bricks
conv = Convolutional(
filter_size=(p["filter_size"], 1),
# step=(p['stride'],1),
num_filters=p["nfilter"],
num_channels=conv_in_channels,
batch_size=batch_size,
border_mode="valid",
tied_biases=True,
name="conv%d" % i,
)
cb.append(conv)
maxpool = MaxPooling(pooling_size=(p["pool_stride"], 1), name="mp%d" % i)
conv_out = conv.apply(conv_in)[:, :, :: p["stride"], :]
conv_out = maxpool.apply(conv_out)
if p["normalize"]:
conv_out_mean = conv_out.mean(axis=2).mean(axis=0)
conv_out_var = ((conv_out - conv_out_mean[None, :, None, :]) ** 2).mean(axis=2).mean(axis=0).sqrt()
conv_out = (conv_out - conv_out_mean[None, :, None, :]) / conv_out_var[None, :, None, :]
if p["activation"] is not None:
conv_out = p["activation"].apply(conv_out)
if p["dropout"] > 0:
b = [p["activation"] if p["activation"] is not None else conv]
dropout_locs.append((VariableFilter(bricks=b, name="output"), p["dropout"]))
if p["skip"] is not None and len(p["skip"]) > 0:
maxpooladd = MaxPooling(pooling_size=(p["stride"] * p["pool_stride"], 1), name="Mp%d" % i)
skip = []
if "max" in p["skip"]:
skip.append(maxpooladd.apply(conv_in)[:, :, : conv_out.shape[2], :])
if "min" in p["skip"]: