C3W1 ungraded lab 1

Getting an error for " Instantiate the Tuner and perform hypertuning", was this lab tested?


ValueError Traceback (most recent call last)
in
5 factor=3,
6 directory=‘kt_dir’,
----> 7 project_name=‘kt_hyperband’)

7 frames
/usr/local/lib/python3.7/dist-packages/keras_tuner/tuners/hyperband.py in init(self, hypermodel, objective, max_epochs, factor, hyperband_iterations, seed, hyperparameters, tune_new_entries, allow_new_entries, **kwargs)
374 )
375 super(Hyperband, self).init(
→ 376 oracle=oracle, hypermodel=hypermodel, **kwargs
377 )
378

/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/tuner.py in init(self, oracle, hypermodel, max_model_size, optimizer, loss, metrics, distribution_strategy, directory, project_name, logger, tuner_id, overwrite, executions_per_trial)
114 project_name=project_name,
115 logger=logger,
→ 116 overwrite=overwrite,
117 )
118

/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/base_tuner.py in init(self, oracle, hypermodel, directory, project_name, logger, overwrite)
101 self._display = tuner_utils.Display(oracle=self.oracle)
102
→ 103 self._populate_initial_space()
104
105 if not overwrite and tf.io.gfile.exists(self._get_tuner_fname()):

/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/base_tuner.py in _populate_initial_space(self)
133
134 while True:
→ 135 self.hypermodel.build(hp)
136
137 # Update the recored scopes.

in model_builder(hp)
21 # Add next layers
22 model.add(keras.layers.Dropout(0.2))
—> 23 model.add(keras.layers.Dense(10, activation=‘softmax’))
24
25 # Tune the learning rate for the optimizer

/usr/local/lib/python3.7/dist-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
627 self._self_setattr_tracking = False # pylint: disable=protected-access
628 try:
→ 629 result = method(self, *args, **kwargs)
630 finally:
631 self._self_setattr_tracking = previous_value # pylint: disable=protected-access

/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
—> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

/usr/local/lib/python3.7/dist-packages/keras/engine/sequential.py in add(self, layer)
182 if not self._is_layer_name_unique(layer):
183 raise ValueError(
→ 184 'All layers added to a Sequential model ’
185 f’should have unique names. Name “{layer.name}” is already the name ’
186 'of a layer in this model. Update the name argument ’

ValueError: All layers added to a Sequential model should have unique names. Name “dense_1” is already the name of a layer in this model. Update the name argument to pass a unique name.

From the error it seems you have 2 layers with the same name. You could change their names (or at least one of them) from where the model is defined and try again to run the lab.