1. 程式人生 > >tensorflow-判斷tensor是否為小數

tensorflow-判斷tensor是否為小數

sta com mail default import fault 小數 spl utf

#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @author: myhaspl @email:[email protected] """ import tensorflow as tf g=tf.Graph() with g.as_default(): x=tf.constant([[4.00, 3.33], [2.34, 7.00]]) y=tf.cast(tf.equal(tf.cast(tf.cast(x,tf.int32),tf.float32),x),tf.int32) with tf.Session(graph=g) as sess: print sess.run(y) [[1 0] [0 1]]

tensorflow-判斷tensor是否為小數