Python - AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes'

Python - AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes'

这与我在这里的问题有关。

我现在更新后的代码如下:

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D
import pickle

X = pickle.load(open("X.pickle","rb"))
y = pickle.load(open("y.pickle","rb"))

X = X/255.0;

model = Sequential()
model.add(Conv2D(64,(3,3),input_shape = X.input_shape[:1]))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2,2)))

model.add(Conv2D(64),(3,3))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2,2)))

model.add(Flatten())
model.add(Dense(64))

model.add(Activation("sigmoid"))

model.compile(loss="binary_crossentropy",
              optimizer = "data",
              metrics=['accuracy'])
model.fit(X,y,batch_size = 32, validation_split = 0.1)

当我尝试训练我的程序时,出现此错误,但实际结果将开始训练我的数据。

Traceback (most recent call last):
  File "intermediate.py", line 12, in <module>
    model.add(Conv2D(64,(3,3),input_shape = X.input_shapes[:1]))
AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes'

我该如何解决这个问题?

谢谢。

使用X.shape代替X.input_shapes