Hello, I'm a beginner in my first week of Python.
I am writing a code like this, but an error occurred and I cannot proceed from here.I don't even know what the error is about in the first place.
As for the code, I just copied it after watching YouTube, but the YouTube video went on without any errors, but when I did it, I got an error.
Could you tell me who can solve this problem?
from keras.applications.vgg16import VGG16
from keras.models import Sequential
from keras.models import model_from_json
from keras.models import Model
from keras.layers import Input, Activities, merge, Dense, Flatten, Dropout
from tensorflow.keras.optimizers import Adam
input_tensor=Input(shape=(224,224,3))
base_model=VGG16(weights='imagenet', input_tensor=input_tensor, include_top=False)
# afterthought
top_model=Sequential()
top_model.add(Flatten(input_shape=base_model.output_shape[1:]))
top_model.add(Dense(n_classes, activation='softmax'))
# connection
model=Model(inputs=base_model.input, outputs=top_model(base_model.output))
# the unlearned class
for layer in model.layer [:15]:
layer.trainable=False
print('#layer=',len(model.layer))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.summary()
The reason is typo.
The last s
in Activities
is unnecessary.
In Dropout
, o
is missing and Dropout
is correct.
Also, it seems that it is not possible to import merge
because the situation has changed since the video was created.
The source code for the part you mentioned in the question does not seem to use merge
, so you may want to delete it.
However, if you use merge
in the future, you will need to rewrite it.
Isn't the line like this?
from keras.layers import Input, Activation, Dense, Flatten, Dropout
© 2025 OneMinuteCode. All rights reserved.