我正在处理代码
https://www.tensorflow.org/tutorials/sequences/text_generation
当我到达该行时,会产生以下错误。
sampled_indices = tf.random.categorical(example_batch_predictions[0], num_samples=1)
sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy()
错误
AttributeError
Traceback (most recent call last)
在
----> 1 sampled_indices = tf.random.categorical(example_batch_predictions[0], num_samples=1)
2 sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy()
AttributeError: module 'tensorflow._api.v1.random' has no attribute 'categorical'
系统信息 - TensorFlow版本:1.12 Uupntu上的Jupyter NoteBooks
tf.random.categorical可能已更改为tf.random.multinomial,假设example_batch_predictions是logits:https://www.tensorflow.org/api_docs/python/tf/random/multinomial
了解行业+人工智能最先进的技术和实践,参与行业+人工智能实践项目