- 博客(8)
- 收藏
- 关注
原创 numpy某些语句用法
random npr_ npdot npreshape nparange .randomnp.random.randn(2,4) #生成了2行4列的标准正态分布数组; np.random.rand(2,4) #生成了[0,1)范围的2行4列的浮点数随机样本数组; np.random.randint(1,10,(2,3)) # 生成了[1,10)范围的2行3列整数数组; np.random.choic
2017-10-27 14:50:06
468
原创 python某些语句的用法
with open as try语句 open image numpy sorted List extend csc稀疏矩阵 sys模块 元类meta classabc lambda x print不换行 find with open as #有一些任务,可能事先需要设置,事后做清理工作,譬如打开、关闭文件,不用with语句时写成: file = open("/tmp/foo.
2017-10-27 14:48:58
337
原创 mnist训练的cnn模型测试自己的手写数字
拿自己的手写数字试了下之前拿mnist训练的cnn模型;代码和示例中用的cnn代码一样的,最后加了个保存模型和处理图像的部分;saver = tf.train.Saver() # defaults to saving all variables;记录; saver.save(sess, '.../number_model.ckpt') #保存模型参数;#加了一个函数处理图像; def image
2017-10-27 14:21:35
1983
原创 TensorFlow基本操作及函数
基本结构 import tensorflow as tf a = tf.placeholder("float",[None,2]) # 占位符,"float"是64位的;tf.float32是32位的; b = tf.placeholder(tf.float32, [2,1 ])#任意行,20列的x。 y = tf.matmul(a, b) #op节点;tf.matmul是点积,还有很多
2017-10-25 14:13:16
262
原创 TensorFlow的cnn做mnist例子
卷积神经网络卷积神经网络第二节用卷积神经网络做下mnist的手写数字识别。一个讲为什么要用relu做隐藏层激活函数的视频花了一两天专门看了下卷积神经网络及相关各种理论基础;找时间还是要继续系统的看下deep learning。#卷积神经网络,加入噪声避免抵消。def weight_variable(shape): initial = tf.truncated_normal(shape, st
2017-10-25 10:36:37
658
原创 TensorFlow的softmax regression做mnist例子
用的就是官方文档中文版入门,试验到mnist文件做softmax regression,坑有点多,记录下。 mnist官网下载 mnist由theano处理过的包下载下载完后测试代码如下,第0张图片输出结果标签应该是5,图片是个5。import pickle #教程中是cPickle包,python3中改名为pickle import gzipimport numpy from PIL impor
2017-10-20 10:35:18
383
原创 one hot encoding/哑编码
>>>from sklearn.preprocessing import OneHotEncoder >>>enc = OneHotEncoder() >>>enc.fit([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]]) #一个4行3列的数组,即有4个样本,3个特征; >>>enc.n_values_#每个特征的取值个数(第一列共有2个取值,第二列有3
2017-06-20 14:13:32
2461
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅