def sparse_categorical_accuracy(y_true, y_pred):
 y_true = tf.cast(y_true, tf.float32)
 y_pred = tf.cast(tf.argmax(y_pred, (len(y_pred.get_shape()) - 1)), tf.float32)
 return tf.reduce_mean(tf.cast(tf.equal(y_true, y_pred), tf.float32))

def sparse_categorical_accuracy ( y_true , y_pred ) : y_true = tf . cast ( y_true , tf . float32 ) y_pred = tf . cast ( tf . argmax ( y_pred , ( len ( y_pred . get_shape ( ) ) - 1 ) ) , tf . float32 ) return tf . reduce_mean ( tf . cast ( tf . equal ( y_true , y_pred ) , tf . float32 ) )
multi-class prediction accuracy .