代码之家  ›  专栏  ›  技术社区  ›  ffejrekaburb

TensorFlow文本生成

  •  1
  • ffejrekaburb  · 技术社区  · 7 年前

    我正在查密码
    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版本:Ubuntu上的1.12 Jupyter笔记本

    有什么可能会丢失的指针吗?我想知道是否有进口丢失?

    1 回复  |  直到 7 年前
        1
  •  3
  •   Leo Lee    7 年前

    tf.random.categorical可能已更改为tf.random.multinomial,假设示例“批处理预测是逻辑: https://www.tensorflow.org/api_docs/python/tf/random/multinomial