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), y.shape)
Success #stdin #stdout 1.29s 196488KB
stdin
Standard input is empty
stdout
(<tf.Tensor 'Shape:0' shape=(3,) dtype=int32>, TensorShape([Dimension(4), Dimension(1), Dimension(2)]))