简体   繁体   中英

How to confirm Keras is loading resnet pretrained nets

I am currently trying to use a pretrained ResNet50 model for my TensorFlow program. When running the train python script, I am not getting a clear indicator that it is using ResNet. Here is a snippet of the code that I have in my train script where ResNet is being used:

from tensorflow.keras.applications import ResNet50

base_model = base_model_fn(ResNet50)
final_model = build_model(base_model, num_classes)

model = Model(inputs=base_model.input, outputs=final_model)

When I run the code, it says that it is creating directories for re.net and then dumps tool data into them, but it should show a download bar and install the pretrained.nets, right? Where would I check to make sure it is using re.net?

You could try it this way

img_shape = (224,224) # set this to the desired size

base_model=tf.keras.applications.ResNet50V2( include_top=False, input_shape=img_shape, 
                               pooling='max', weights='imagenet')
x=base_model.output
output=Dense(num_classes, activation='softmax')(x)
model=Model(inputs=base_model.input, outputs=output)
model.summary()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM