After some changes in my graphics card, even during using CPU, my tensorflow does not work properly.
TensorFlow version: 1.15.0
Keras version: 2.2.4-tf
I can call for the version and I can use functions like tf.matmul and they work. But when I load any model:
model_file_name = ‘model_1_20240311_2116’
model_best_2 = keras.models.load_model(f’{address}ML_models\{model_file_name}')
I get this message:
JSONDecodeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_25020\3662249631.py in
3 model_file_name = ‘model_1_20240311_2116’ #input
4
----> 5 model_best_2 = keras.models.load_model(f’{address}ML_models\{model_file_name}‘)
6
7 with open(f’{address}ML_models\{model_file_name}.json’, ‘r’) as file:
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\save.py in load_model(filepath, custom_objects, compile)
145 if isinstance(filepath, six.string_types):
146 loader_impl.parse_saved_model(filepath)
→ 147 return saved_model_load.load(filepath, compile)
148
149 raise IOError(
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\saved_model\load.py in load(path, compile)
84 # TODO(kathywu): Add saving/loading of optimizer, compiled losses and metrics.
85 # TODO(kathywu): Add code to load from objects that contain all endpoints
—> 86 model = tf_load.load_internal(path, loader_cls=KerasObjectLoader)
87
88 if isinstance(model, RevivedModel) and compile:
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in load_internal(export_dir, tags, loader_cls)
541 loader = loader_cls(object_graph_proto,
542 saved_model_proto,
→ 543 export_dir)
544 root = loader.get(0)
545 root.tensorflow_version = meta_graph_def.meta_info_def.tensorflow_version
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\saved_model\load.py in init(self, *args, **kwargs)
100
101 def init(self, *args, **kwargs):
→ 102 super(KerasObjectLoader, self).init(*args, **kwargs)
103 self._finalize()
104
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in init(self, object_graph_proto, saved_model_proto, export_dir)
119 self._concrete_functions[name] = _WrapperFunction(concrete_function)
120
→ 121 self._load_all()
122 # TODO(b/124045874): There are limitations with functions whose captures
123 # trigger other functions to be executed. For now it is only guaranteed to
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in _load_all(self)
237 # interface.
238 continue
→ 239 node, setter = self._recreate(proto)
240 nodes[node_id] = node
241 node_setters[node_id] = setter
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in _recreate(self, proto)
320 if kind not in factory:
321 raise ValueError(“Unknown SavedObject type: %r” % kind)
→ 322 return factorykind
323
324 def _recreate_user_object(self, proto):
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in ()
307 “”“Creates a Python object from a SavedObject protocol buffer.”“”
308 factory = {
→ 309 “user_object”: lambda: self._recreate_user_object(proto.user_object),
310 “asset”: lambda: self._recreate_asset(proto.asset),
311 “function”: lambda: self._recreate_function(proto.function),
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\saved_model\load.py in _recreate_user_object(self, proto)
326 looked_up = revived_types.deserialize(proto)
327 if looked_up is None:
→ 328 return self._recreate_base_user_object(proto)
329 return looked_up
330
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\saving\saved_model\load.py in _recreate_base_user_object(self, proto)
173 if parent_classes is not None:
174 parent_classes = revived_classes[proto.identifier]
→ 175 metadata = json.loads(proto.metadata)
176 revived_cls = type(
177 compat.as_str(metadata[‘class_name’]),
~\AppData\Local\Programs\Python\Python37\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
→ 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder
~\AppData\Local\Programs\Python\Python37\lib\json\decoder.py in decode(self, s, _w)
335
336 “”"
→ 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
~\AppData\Local\Programs\Python\Python37\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
→ 355 raise JSONDecodeError(“Expecting value”, s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
#########################################################################
And if I want to train a model
initializer = tf.keras.initializers.GlorotUniform(seed=0) #loss: 0.4888 good
I get this error:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_8940\2572992766.py in
6 # initializer = tf.keras.initializers.GlorotNormal() loss: 0.4909
7 # initializer = tf.keras.initializers.RandomUniform(minval=-0.03, maxval=0.03) #loss: 0.5035
----> 8 initializer = tf.keras.initializers.GlorotUniform(seed=0) #loss: 0.4888 good
9
10
~\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\util\module_wrapper.py in getattr(self, name)
191 def getattr(self, name):
192 try:
→ 193 attr = getattr(self._tfmw_wrapped_module, name)
194 except AttributeError:
195 if not self._tfmw_public_apis:
AttributeError: module ‘tensorflow.python.keras.api._v1.keras.initializers’ has no attribute ‘GlorotUniform’