0

我在我的机器上运行关于 CNN 的代码,但它得到了一个错误反馈。

我的代码片段:

model.add(Convolution2D(4 ,3 ,5, 5, border_mode='valid' ,input_shape=(200,200,3))) 

我也尝试:

model.add(Convolution2D(4 ,3 ,5, 5, border_mode='valid' ,input_shape=(3,200,200))) 

错误是:


Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
    execfile(filename, namespace)
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "/Users/liumengyang/Desktop/visual/pre-processing.py", line 61, in 
    model.add(Convolution2D(4 ,3 ,5, 5, border_mode='valid' ,input_shape=(200,200,3))) 
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/keras/models.py", line 280, in add
    layer.create_input_layer(batch_input_shape, input_dtype)
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/keras/engine/topology.py", line 370, in create_input_layer
    self(x)
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/keras/engine/topology.py", line 487, in __call__
    self.build(input_shapes[0])
  File "/Users/liumengyang/anaconda/lib/python3.5/site-packages/keras/layers/convolutional.py", line 410, in build
    self.W = self.init(self.W_shape, name='{}_W'.format(self.name))
TypeError: 'int' object is not callable

如何解决这个问题呢?

4

1 回答 1

0

我想你可能对 tensorflow 的语法感到困惑。

您的陈述中有一些错字model.add(Convolution2D(4 ,3 ,5, 5, border_mode='valid' ,input_shape=(200,200,3))),,

model.add(Convolution2D(4 ,5, 5, border_mode='valid' ,input_shape=(200,200,3)))如果您想要 4 个大小为 5x5 的过滤器,请尝试此操作。

于 2016-11-23T03:36:52.393 回答