def check_for_zero(sparse):
 with tf.device('/cpu:0'):
  shape = tf.shape(sparse)
  batch_size = shape[0]
  sparse = tf.minimum(sparse, 1)
  indices = (sparse + (2 * tf.range(0, batch_size)))
  dense = tf.sparse_to_dense(indices, tf.expand_dims((2 * batch_size), 0), 1.0, 0.0)
  reshaped = tf.reshape(dense, [(-1), 2])
 return tf.reshape(tf.slice(reshaped, [0, 0], [(-1), 1]), [(-1)])

def check_for_zero ( sparse ) : with tf . device ( '/cpu:0' ) : shape = tf . shape ( sparse ) batch_size = shape [ 0 ] sparse = tf . minimum ( sparse , 1 ) indices = ( sparse + ( 2 * tf . range ( 0 , batch_size ) ) ) dense = tf . sparse_to_dense ( indices , tf . expand_dims ( ( 2 * batch_size ) , 0 ) , 1.0 , 0.0 ) reshaped = tf . reshape ( dense , [ ( - 1 ) , 2 ] ) return tf . reshape ( tf . slice ( reshaped , [ 0 , 0 ] , [ ( - 1 ) , 1 ] ) , [ ( - 1 ) ] )
in a sparse batch of ints .