0
点赞
收藏
分享

微信扫一扫

InvalidArgumentError: assertion failed: [0] [Op:Assert] name: EagerVariableNameReuse

_karen 2023-10-08 阅读 36

 

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
Cell In[2], line 32
     25 y_train = np.array(y_train)
     27 model = tf.keras.Sequential([
     28     SimpleRNN(3),
     29     Dense(5, activation='softmax')
     30 ])
---> 32 model.compile(optimizer=tf.keras.optimizers.Adam(0.01),
     33               loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
     34               metrics=['sparse_categorical_accuracy'])
     36 checkpoint_save_path = "./rnn_onehot_1pre1.ckpt"
     38 if os.path.exists(checkpoint_save_path + '.index'):

File /home/software/anaconda3/envs/mydlenv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:329, in Model.compile(self, optimizer, loss, metrics, loss_weights, sample_weight_mode, weighted_metrics, **kwargs)
    326 self._run_eagerly = kwargs.pop('run_eagerly', None)
    328 self.optimizer = self._get_optimizer(optimizer)
--> 329 self.compiled_loss = compile_utils.LossesContainer(
    330     loss, loss_weights, output_names=self.output_names)
    331 self.compiled_metrics = compile_utils.MetricsContainer(
    332     metrics, weighted_metrics, output_names=self.output_names)
    334 # Initializes attrs that are reset each time `compile` is called.

File /home/software/anaconda3/envs/mydlenv/lib/python3.8/site-packages/tensorflow/python/keras/engine/compile_utils.py:120, in LossesContainer.__init__(self, losses, loss_weights, output_names)
    118 self._loss_weights = loss_weights
    119 self._per_output_metrics = None  # Per-output losses become metrics.
--> 120 self._loss_metric = metrics_mod.Mean(name='loss')  # Total loss.
    121 self._built = False

File /home/software/anaconda3/envs/mydlenv/lib/python3.8/site-packages/tensorflow/python/keras/metrics.py:470, in Mean.__init__(self, name, dtype)
    463 def __init__(self, name='mean', dtype=None):
    464   """Creates a `Mean` instance.
    465 
    466   Args:
    467     name: (Optional) string name of the metric instance.
    468     dtype: (Optional) data type of the metric result.
    469   """
--> 470   super(Mean, self).__init__(
    471       reduction=metrics_utils.Reduction.WEIGHTED_MEAN, name=name, dtype=dtype)

File /home/software/anaconda3/envs/mydlenv/lib/python3.8/site-packages/tensorflow/python/keras/metrics.py:307, in Reduce.__init__(self, reduction, name, dtype)
    305 self.reduction = reduction
    306 with ops.init_scope():
--> 307   self.total = self.add_weight(
    308       'total', initializer=init_ops.

举报

相关推荐

C++报错 Debug Assertion Failed

0 条评论