2018年6月22日

在对csv文件做批量获取时无法获取,程序不动

摘要: 代码如下: coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) for step in range(100): #获取正真的样本和标签 example, label = sess.run 阅读全文

posted @ 2018-06-22 22:58 blueslichanghui 阅读(116) 评论(0) 推荐(0) 编辑

tensorflow 对csv数据进行批量获取

摘要: 代码如下: #读取文件数据 def read_data(file_queue): # 读取的时候需要跳过第一行 reader = tf.TextLineReader(skip_header_lines=1) key, value = reader.read(file_queue) # 对于数据源中空 阅读全文

posted @ 2018-06-22 22:57 blueslichanghui 阅读(245) 评论(0) 推荐(0) 编辑

tensorflow 做多元线性回归时怎样对非数据型数据(分类型数据)进行处理(编码)

摘要: 代码如下: def read_data(file_queue): ''' the function is to get features and label (即样本特征和样本的标签) 数据来源是csv的文件,采用tensorflow 自带的对csv文件的处理方式 :param file_queue 阅读全文

posted @ 2018-06-22 22:57 blueslichanghui 阅读(208) 评论(0) 推荐(0) 编辑

flatten函数

摘要: numpy.ndarray.flatten ,返回一个一维的数组,作用的对象可以是numpy对象,即数组或者是矩阵对象,不可以是列表 阅读全文

posted @ 2018-06-22 22:56 blueslichanghui 阅读(235) 评论(0) 推荐(0) 编辑

用 sklearn包中的 linear_model 实现多元线性回归

摘要: from sklearn import linear_model reg = linear_model.LinearRegression() reg.fit(example, label) print("Coefficients of sklearn: W=%s, b=%f" % (reg.coef 阅读全文

posted @ 2018-06-22 22:55 blueslichanghui 阅读(562) 评论(0) 推荐(0) 编辑

tensorflow实现多元线性回归时预测出的参数为nan

摘要: 这是由于在用feed_dict 进行数据喂养之前没有做数据归一化: 解决办法: 使用sklearn包中的preprocessing做归一化: 大妈如下 阅读全文

posted @ 2018-06-22 22:54 blueslichanghui 阅读(358) 评论(0) 推荐(0) 编辑

TypeError: Input 'y' of 'Equal' Op has type string that does not match type int32 of argument 'x'.

摘要: 这是在做用tensorflow读取csv文件中数据时,设置默认值时与数据源中的数据格式不匹配,即,上面的意思是,csv文件中的数据类型是字符型的,而我们设置默认值时设置的时int32型的不匹配 阅读全文

posted @ 2018-06-22 22:54 blueslichanghui 阅读(316) 评论(0) 推荐(0) 编辑

ValueError: Cannot feed value of shape (2,) for Tensor u'Placeholder_2:0', which has shape '(1, 2)'

摘要: 在tensorflow中你在做数据喂养的时候你输入的是一个一维数组如:[22,33],他的shape 为(2,) 在tensorflow中一维数组是不能与同样的一维数组进行运算的,必须通过reshape成为(1,2)而 另一个一维数组必须是(2,1)才能相乘,但是在numpy中两个一维数组相乘是不会 阅读全文

posted @ 2018-06-22 22:53 blueslichanghui 阅读(2000) 评论(0) 推荐(0) 编辑

shape 函数,以及shape(2,)和shape(2,1)区别

摘要: 1:一般的数组如:【22,33】 shape是(2,):他表示他是一个一维数组,数组中有两个元素;注意他和shape(2,1)的区别,他两个不一样。 2:[[22],[33]] 他的shape是(2,1),表示二维数组,每行有一个元素 3:[[22,33]] shape是(1,2) 他表示一个二维数 阅读全文

posted @ 2018-06-22 22:50 blueslichanghui 阅读(960) 评论(0) 推荐(0) 编辑

reshape函数第一个参数-1是什么意思

摘要: 比如一个数组【1,2,3,4,5】 shape是(5,) reshape(-1,1)的结果是: [[1] [2] [3] [4] [5]] 是一个一行5行1列的二维数组,shape为(5,1) 让我们再来看看reshape(-1,2)呢:ValueError: cannot reshape arra 阅读全文

posted @ 2018-06-22 22:50 blueslichanghui 阅读(4671) 评论(0) 推荐(0) 编辑

导航