首页 > 解决方案 > NameError:未定义名称“example_batch_predictions”

问题描述

我正在运行代码并收到此错误。代码如下。

for input_example_batch, target_example_batch in dataset.take(1): 
example_batch_predictions = model(input_example_batch)
print(example_batch_predictions.shape,"(BATCH_SIZE, sequence_length,vocab_size)")

model.summary()

sampled_indices = tf.random.categorical(example_batch_predictions,num_samples=1)
sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy()

我收到的错误是

NameError Traceback (最近一次调用最后一次) ipython-input-45-f7c2773af286> in module() sampled_indices = tf.random.categorical(example_batch_predictions, num_samples=1) sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy( )

NameError:未定义名称“example_batch_predictions”

标签: pythonpython-3.xpython-2.7tensorflowmachine-learning

解决方案


推荐阅读