本文共 1956 字,大约阅读时间需要 6 分钟。
scipy.ndimage
: submodule dedicated to image processing (n-dimensional images).
PIL: The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities.
d["Y_prediction_test"][0,index]
: d is a dictionary
test_set_x[:,index].reshape((num_px, num_px, 3))
[:,index]
所有的行,index 列(切片)imshow()
: 输出图像
In order for Gradient Descent to work you must choose the learning rate wisely. The learning rate α \alpha α determines how rapidly we update the parameters. If the learning rate is too large we may “overshoot” the optimal value. Similarly, if it is too small we will need too many iterations to converge to the best values.
%matplotlib inline
: 内嵌画图,是 Magic Function,IPython 预先定义好的函数
W1 = np.random.randn(n_h, n_x) * 0.01
、b1 = np.zeros((n_h, 1))
初始化,注意括号和系数 (0.01)
函数 convert_to_one_hot(Y, C)
Y = np.eye(C)[Y.reshape(-1)]
,后面的数组表明1偏移的位置 将离散型特征进行one-hot编码是为了让距离计算更合理 tf.transpose()
对二维数组说就是转置
eval()
其实就是 tf.Tensor
的 Session.run()
的另外一种写法,eval()
只能用于 tf.Tensor
类对象,有输出的 Operation
always returns a copy.
returns a view of the original array whenever possible. This isn’t visible in the printed output, but if you modify the array returned by ravel, it may modify the entries in the original array. If you modify the entries in an array returned from flatten this will never happen. ravel will often be faster since no memory is copied, but you have to be more careful about modifying the array it returns.
numpy.random.permutation(x)
np.random,randn()
返回的是正态分布,np.random,rand()
返回的是均匀分布
argmax(array, axis=None)
np.int64(A > 0)
,A中大于0的元素全部转化为1,小于0的元素全部转化为0
x1 = np.squeeze(x)
把 x 中维度为1的去掉中括号,序列化
转载地址:http://tudii.baihongyu.com/