Mask_RCNN
Mask_RCNN copied to clipboard
'SGD' object has no attribute 'get_updates'
AttributeError Traceback (most recent call last)
~\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.
@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 . i've done some changes in the model.py file inside the mrcnn folder worked for me.
specifically i changed the line
2168-> optimizer = tf.keras.optimizers.SGD(....) to
2168-> optimizer = tf.keras.optimizers.legacy.SGD(...)
Ok thanks for the help. Had to change some things on system files, it worked fine after that.
@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.