-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: module 'keras.utils' has no attribute 'get_file' #74
Comments
I encountered the same error and It was because the weights parameter was explicitly assigned to imagenet while calling the ResNet18 model. As per documentation, the pretrained imagenet weights are set as default for the model if not set to None. @TDL77 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-- for keras
from classification_models.keras import Classifiers
--передаю как np.array ...images
ResNet18, preprocess_input = Classifiers.get('resnet18')
X = preprocess_input(images)
--prepare your data
--Split the loaded dataset into train, test sets
X_train, X_test, y_train, y_test = train_test_split(X, labels,
test_size = 0.2,
random_state = random_seed ,
stratify = labels)
print("x_train shape = ",X_train.shape)
print("y_train shape = ",y_train.shape)
print("\nx_test shape = ",X_test.shape)
print("y_test shape = ",y_test.shape)
--x_train shape = (9754, 180, 180, 3)
--y_train shape = (9754,)
--x_test shape = (2439, 180, 180, 3)
--y_test shape = (2439,)
n_classes = 40
--build model
base_model = ResNet18(input_shape=(sz,sz,3), weights='imagenet', include_top=False)
x = keras.layers.GlobalAveragePooling2D()(base_model.output)
output = keras.layers.Dense(n_classes, activation='softmax')(x)
model = keras.models.Model(inputs=[base_model.input], outputs=[output])
--train
model.compile(optimizer='SGD', loss='categorical_crossentropy', metrics=['accuracy'])
history = model.fit(x_train, y_train,
epochs=100,
batch_size=32,
validation_data = (x_test, y_test)
callbacks=[callbacks],
class_weight=class_weights
)
...и вот дальше вылазит эта ошибка
AttributeError: module 'keras.utils' has no attribute 'get_file'
...подскажи а можно передать через ?
train_generator = train_datagen.flow_from_directory( base_path,
target_size=(sz,sz),..............
The text was updated successfully, but these errors were encountered: