Home > Enterprise >  URL fetch failure on resnet50_weights_tf
URL fetch failure on resnet50_weights_tf

Time:06-30

I have to train a model from where I dont have access to Internet.

base_cnn = resnet.ResNet50(
    weights="imagenet", input_shape=target_shape   (3,), include_top=False
)

Subsequently, training is failing with:

Traceback (most recent call last):
    base_cnn = resnet.ResNet50(
      return ResNet(stack_fn, False, True, 'resnet50', include_top, weights,
      weights_path = data_utils.get_file(
      raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5: None -- [Errno 101] Network is unreachable

Is there a way I can load the weights from drive instead of fetching an URL?

CodePudding user response:

Weights could be downloaded as:

from tensorflow.keras.applications import resnet

base_cnn = resnet.ResNet50(
    weights="imagenet", input_shape=target_shape   (3,), include_top=False
)

base_cnn.save("weights.h5")

Then load the saved weights:

from tensorflow.keras.models import load_model
base_cnn=load_model('weights.h5')
  • Related