我正在使用以下代码:
input_shape = (75, 75, 3)
x = Input(input_shape)
model = BatchNormalization(axis = 3)(x)
上面的代码工作正常。但是,以下代码不起作用:
from keras.models import Sequential
input_shape = (64,64,3)
model = Sequential()
model = model.add(InputLayer(input_shape=input_shape))
model = model.add(BatchNormalization(axis = 3))
但在最后一行,我得到错误:
AttributeError: 'NoneType' object has no attribute 'add'
如果我改为:
model = model.add(Input(input_shape))
我收到以下错误:
TypeError: The added layer must be an instance of class Layer.
Found: Tensor("input_1:0", shape=(?, 64, 64, 3), dtype=float32)
问题出在哪里,如何解决?
(PS:如果你觉得这个问题很有趣/很重要,请点赞。)