ffejrekaburb
ffejrekaburb

Reputation: 731

Tensorflow text_generation

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?

Upvotes: 2

Views: 1007

Answers (1)

Leo Lee
Leo Lee

Reputation: 66

tf.random.categorical probably has been changed to tf.random.multinomial, assuming example_batch_predictions are logits: https://www.tensorflow.org/api_docs/python/tf/random/multinomial

Upvotes: 4

Related Questions