fork download
  1. import tensorflow as tf
  2. import numpy as np
  3.  
  4. a = np.zeros((4,2))
  5. b = tf.random.categorical(a, 1)
  6. x = b
  7. y = tf.one_hot(x, depth=2)
  8. print(tf.shape(y))
Success #stdin #stdout 1.05s 197896KB
stdin
Standard input is empty
stdout
Tensor("Shape:0", shape=(3,), dtype=int32)