Open glushakviktor opened 3 years ago
were you able to solve this?
最后一层之前 Flatten 一下就好,模型示例如下:
you need to match output dimension of your network with label dimension, so you can use GlobalAveragePooling 2D or 3D layer(depend on data shape, here 2D), or Flatten layer after Dense layer.
model = models.Sequential() model.add(layers.Dense(256, activation='relu', input_dim= 4 4 512)) model.add(layers.Dropout(0.5)) model.add(GlobalAveragePooling2D()) or model.add(Flatten()) model.add(layers.Dense(1, activation='sigmoid'))
最后一层之前 Flatten 一下就好,模型示例如下:
This solution worked for me. Thanks @lbjai and @alibaghayeri
I didn't quite have the same err as the OP, but hopefully I might be able to help anyone else stuck with similar errors.
The problem I had was:
ValueError: logits and labels must have the same shape, received ((None, 1) vs (None, 2)).
This was because when loading data with pandas, the index will be loaded as Unnamed: 0, which will result in the y_data having two columns. And so not working with binary classification. Just a heads up for anyone with this problem!
Solution is simply:
y_train = pd.read_csv(PATH_TO_DATA, index_col=[0])
Hello, can you help me please. When I try to check my result on a test samples. I have an error.
My code same as yours from listings 5.17 to 5.19:
Then after I saved a model, and in another file I loaded it
Then I have the error: