在学习TensorFlow的过程中,我们需要知道某个tensor的值是什么,这个很重要,尤其是在debug的时候.也许你会说,这个很容易啊,直接print就可以了.其实不然,print只能打印输出shape的信息,而要打印输出tensor的值,需要借助class tf.Session, class tf.InteractiveSession.因为我们在建立graph的时候,只建立tensor的结构形状信息,并没有执行数据的操作. 一 class tf.Session 运行tensorflow操作
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1,
获取Tensor维度的两种方法: Tensor.get_shape() 返回TensorShape对象, 如果需要确定的数值而把TensorShape当作list使用,肯定是不行的. 需要调用TensorShape的as_list()方法, 需要调用TensorShape.as_list()方法来获取维度数值. 来实践一下: import tensorflow as tf a = tf.zeros(shape=[10,20]) b = a.get_shape() c = b.as_list()