模块'tensorlayer.layers'没有属性'flatten'

时间:2018-12-23 06:27:35

标签: tensorflow

我正在尝试建立一个二值神经网络,但错误是 “模块'tensorlayer.layers'没有属性'flatten'”

tf.reset_default_graph()
x = tf.placeholder(tf.float32, [None, 1, 48, 1])
net = tl.layers.InputLayer(x, name='input')
net = tl.layers.BinaryConv2d(net, 32, (5, 5), (1, 1), padding='SAME', name='bcnn1')
net = tl.layers.MaxPool2d(net, (2, 2), (2, 2), padding='SAME', name='pool1')
net = tl.layers.BatchNormLayer(net, act=tl.act.htanh, is_train=True,name='bn1')
net = tl.layers.SignLayer(net)
net = tl.layers.BinaryConv2d(net, 64, (5, 5), (1, 1), padding='SAME', name='bcnn2')
net = tl.layers.MaxPool2d(net, (2, 2), (2, 2), padding='SAME', name='pool2')
net = tl.layers.BatchNormLayer(net, act=tl.act.htanh, is_train=True, name='bn2')
net = tl.layers.flatten(net)
net = tl.layers.DenseLayer(net, n_units=40, act = tf.identity, name='output_layer')

1 个答案:

答案 0 :(得分:1)

没有flatten属性。您正在寻找FlattenLayer属性:

net = tl.layers.FlattenLayer(net)