I am trying the import MobilenetV2 in the Azure ML Studio notebook, but I am getting an error. Please note that I can import the model running the same command via Jupyter notebook on my local machine.
import tensorflow as tf
from tensorflow import keras
model = tf.keras.applications.MobileNetV2()
The error log is as below
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [23], in <cell line: 1>()
----> 1 model = tf.keras.applications.MobileNetV2()
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/tensorflow/python/keras/applications/mobilenet_v2.py:405, in MobileNetV2(input_shape, alpha, include_top, weights, input_tensor, pooling, classes, classifier_activation, **kwargs)
402 weight_path = BASE_WEIGHT_PATH + model_name
403 weights_path = data_utils.get_file(
404 model_name, weight_path, cache_subdir='models')
--> 405 model.load_weights(weights_path)
406 elif weights is not None:
407 model.load_weights(weights)
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:250, in Model.load_weights(self, filepath, by_name, skip_mismatch)
246 if (self._distribution_strategy.extended.steps_per_run > 1 and
247 (not network._is_hdf5_filepath(filepath))): # pylint: disable=protected-access
248 raise ValueError('Load weights is not yet supported with TPUStrategy '
249 'with steps_per_run greater than 1.')
--> 250 return super(Model, self).load_weights(filepath, by_name, skip_mismatch)
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/tensorflow/python/keras/engine/network.py:1266, in Network.load_weights(self, filepath, by_name, skip_mismatch)
1263 hdf5_format.load_weights_from_hdf5_group_by_name(
1264 f, self.layers, skip_mismatch=skip_mismatch)
1265 else:
-> 1266 hdf5_format.load_weights_from_hdf5_group(f, self.layers)
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py:659, in load_weights_from_hdf5_group(f, layers)
648 """Implements topological (order-based) weight loading.
649
650 Arguments:
(...)
656 and weights file.
657 """
658 if 'keras_version' in f.attrs:
--> 659 original_keras_version = f.attrs['keras_version'].decode('utf8')
660 else:
661 original_keras_version = '1'
AttributeError: 'str' object has no attribute 'decode'