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 阅读(122) 评论(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 阅读(267) 评论(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 阅读(227) 评论(0) 推荐(0)

flatten函数

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

posted @ 2018-06-22 22:56 blueslichanghui 阅读(255) 评论(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 阅读(581) 评论(0) 推荐(0)

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

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

posted @ 2018-06-22 22:54 blueslichanghui 阅读(373) 评论(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 阅读(336) 评论(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 阅读(2037) 评论(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 阅读(1000) 评论(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 阅读(4819) 评论(0) 推荐(0)

TypeError: Value passed to parameter 'a' has DataType int64 not in list of allowed values: float16,

摘要: 这是我在做多元线性回归时遇到的错误:这个也是数据类型类的错误; 解决办法就是把数据的类型转化之后就行的了,于‘TypeError: Input 'b' of 'MatMul' Op has type int64 that does not match type float32 of argument 阅读全文

posted @ 2018-06-22 22:49 blueslichanghui 阅读(691) 评论(0) 推荐(0)

Shape must be rank 2 but is rank 1 for 'MatMul'

摘要: 我在做多元线性回归的时候,在预测数据时遇到的: 这是由于我录入的数据如:[1,2] 他的shape是[2,],而我在参数(也就是y = w1*x1+w2*x2+b 中的w)用的是placeholder生成, shape是(2,1)的;所以无法进行矩阵乘法; 解决办法是: 在录入数据的时候通过data 阅读全文

posted @ 2018-06-22 22:48 blueslichanghui 阅读(1936) 评论(0) 推荐(0)

TypeError: Input 'b' of 'MatMul' Op has type int64 that does not match type float32 of argument 'a'.

摘要: 在做多元线性回归的时候多余模型:y = tf.matmul(x_data,w) +b 中: 我的x_data 使用tf.placeholder(tf.float32,[1,2]) 申明的; 而我的输入的是整数 解决办法: 1:直接把输入输成浮点型的,如:输入3,你可以直接输入3.00 2:加上类型转 阅读全文

posted @ 2018-06-22 22:48 blueslichanghui 阅读(1098) 评论(0) 推荐(0)

tensorflow基于csv数据集实现多元线性回归并预测

摘要: #coding:utf8 import tensorflow as tf from sklearn import linear_model from sklearn import preprocessing import numpy as np def read_data(file_queue): 阅读全文

posted @ 2018-06-22 22:46 blueslichanghui 阅读(1819) 评论(0) 推荐(0)

导航