fork download
  1. import tensorflow as tf
  2. import numpy as np
  3.  
  4. favourite_song_label = tf.constant([0.3, 0.0, 0.001])
  5. favourite_song_label = tf.where(tf.math.greater(favourite_song_label, tf.constant(0.0, dtype=tf.float32)), tf.ones_like(favourite_song_label, dtype=tf.float32), tf.zeros_like(favourite_song_label, dtype=tf.float32))
  6.  
  7. with tf.Session() as sess:
  8. sess.run(favourite_song_label)
  9. print(favourite_song_label.eval())
  10.  
Success #stdin #stdout 1.44s 201444KB
stdin
Standard input is empty
stdout
[1. 0. 1.]