-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
'SGD' object has no attribute 'get_updates' #2977
Comments
@beingSherlock You must upgrade Tensorflow to version 2.5x or above. Its work for me. |
Ok thanks for the help. Had to change some things on system files, it worked fine after that. |
@beingSherlock Which things did you change on system files? Upgrading to tensorflow 2.5 is not a solution for me, because it is gonna be incompatable with other packages in my environment. I use tensorflow 2.12.0, facing the same issue. |
@beingSherlock can you tell what exactly did you change? |
I had the same error . specifically i changed the line 2168-> optimizer = tf.keras.optimizers.SGD(....) 2168-> optimizer = tf.keras.optimizers.legacy.SGD(...) |
@beingSherlock Can you please tell me what actually needs to change? |
Can you please tell me what exactly need to do in the code or configuration |
@beingSherlock how you resolved it? I am getting the same error and tf.keras.optimizers.legacy.SGD is not working for me! also I'm using version 2.14.0 . Please help anyone who resolved it using version 2.14.0. |
AttributeError Traceback (most recent call last)
in
1 # train weights (output layers or 'heads')
----> 2 model.train(dataset_train, dataset_train, learning_rate=0.001, epochs=5, layers='heads')
~\Downloads\Mask-R-CNN-using-Tensorflow2-main\mrcnn\model.py in train(self, train_dataset, val_dataset, learning_rate, epochs, layers, augmentation, custom_callbacks, no_augmentation_sources)
2367 workers = multiprocessing.cpu_count()
2368
-> 2369 self.keras_model.fit(
2370 train_generator,
2371 initial_epoch=self.epoch,
~\AppData\Roaming\Python\Python38\site-packages\keras\engine\training_v1.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
854
855 func = self._select_training_loop(x)
--> 856 return func.fit(
857 self,
858 x=x,
~\AppData\Roaming\Python\Python38\site-packages\keras\engine\training_generator_v1.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing)
645 y, sample_weight, validation_split=validation_split
646 )
--> 647 return fit_generator(
648 model,
649 x,
~\AppData\Roaming\Python\Python38\site-packages\keras\engine\training_generator_v1.py in model_iteration(model, data, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch, mode, batch_size, steps_name, **kwargs)
280
281 is_deferred = not model._is_compiled
--> 282 batch_outs = batch_function(*batch_data)
283 if not isinstance(batch_outs, list):
284 batch_outs = [batch_outs]
~\AppData\Roaming\Python\Python38\site-packages\keras\engine\training_v1.py in train_on_batch(self, x, y, sample_weight, class_weight, reset_metrics)
1178
1179 self._update_sample_weight_modes(sample_weights=sample_weights)
-> 1180 self._make_train_function()
1181 outputs = self.train_function(ins)
1182
~\AppData\Roaming\Python\Python38\site-packages\keras\engine\training_v1.py in _make_train_function(self)
2282 with backend.name_scope("training"):
2283 # Training updates
-> 2284 updates = self.optimizer.get_updates(
2285 params=self._collected_trainable_weights,
2286 loss=self.total_loss,
AttributeError: 'SGD' object has no attribute 'get_updates'
I'm new to Machine Learning please help me with this error.
The text was updated successfully, but these errors were encountered: