开发者社区> 问答> 正文

Tensorflow text_generation

我正在处理代码
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

展开
收起
一码平川MACHEL 2019-01-18 10:37:18 3130 0
1 条回答
写回答
取消 提交回答
  • tf.random.categorical可能已更改为tf.random.multinomial,假设example_batch_predictions是logits:https://www.tensorflow.org/api_docs/python/tf/random/multinomial

    2019-07-17 23:25:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Large scale text processing pipeline with Spark ML and GraphFrames 立即下载
TensorRT Introduction 立即下载
TensorRT Introduction 立即下载