Tensorflow text_generation

Viewed 918

I'm working through the code
https://www.tensorflow.org/tutorials/sequences/text_generation

When I arrive at the line the following error is produced.

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

Error

AttributeError
Traceback (most recent call last)

in

----> 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'

System information - TensorFlow version: 1.12 Jupyter NoteBooks on Ubuntu

Any pointers for what could be missing? I'm wondering if there is an import missing?

1 Answers
Related