Athony

波斯顿房价经典问题
title: 波斯顿房经典问题 date: 2018-11-7 22:55:33 tags: mathjax: ...
扫描右侧二维码阅读全文
18
2019/06

波斯顿房价经典问题


title: 波斯顿房经典问题
date: 2018-11-7 22:55:33
tags:
mathjax: true

import tensorflow as tf
v=tf.Variable(0,tf.int32)
x=tf.constant(1,tf.int32)
sum=tf.Variable(0,tf.int32)
new_v=tf.add(v,x)
new_sum=tf.add(sum,v)
update1=tf.assign(sum,new_sum)
update=tf.assign(v,new_v)
init_op=tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init_op)
    for i in range(10):
        sess.run(update1)
        sess.run(update)
    print(sess.run(new_sum))
#准备阶段
#已经修改
%matplotlib inline   
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as  np
import pandas as pd
from sklearn.utils import shuffle#打乱数据
C:\ProgramData\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
data_read=pd.read_csv("boston.csv")
#data_read
data=data_read.values
df=np.array(data)
for  i in range(12):
    df[:,i]=(df[:,i]-df[:,i].min())/(df[:,i].max()-df[:,i].min())
x_d=df[:,:12]
y_d=df[:,12]
x=tf.placeholder(tf.float32,[None,12])
y=tf.placeholder(tf.float32,[None,1])
with tf.name_scope("Model"):
    w=tf.Variable(tf.random_normal([12,1],stddev=0.01))
    b=tf.Variable(1.0)
    def model(x,w,b):
        return tf.matmul(x,w)+b
    pred=model(x,w,b)
train_step=100
#训练准备
with tf.name_scope("Loss"):
    loss_f=tf.reduce_mean(tf.pow((y-pred),2))
#优化器
optimizer=tf.train.GradientDescentOptimizer(learning_rate=0.01).minimize(loss_f)
#with tf.Session() as sess:
sess=tf.Session()
init=tf.global_variables_initializer()
sess.run(init)
for i in range(train_step):
    loss_sum=0.0
    for xs,ys in zip(x_d,y_d):
        xs = xs.reshape(1,12)
        ys = ys.reshape(1,1)
        _,loss = sess.run([optimizer,loss_f],feed_dict={x:xs,y:ys})
        loss_sum = loss_sum +loss
    x_d,y_d=shuffle(x_d,y_d)

    b0temp=b.eval(session=sess)
    w0temp=w.eval(session=sess)
    loss_av=loss_sum/len(y_d)
    print(i+1,"loss=",loss_av,"b=",b0temp,"w=",w0temp)
1 loss= 77.27488620112845 b= 15.160501 w= [[-1.7482743 ]
 [ 6.0702925 ]
 [-1.513473  ]
 [ 3.59399   ]
 [-0.71557933]
 [13.37207   ]
 [ 2.5852275 ]
 [ 4.898767  ]
 [-2.6042056 ]
 [-2.8547196 ]
 [ 0.21967784]
 [-5.7239017 ]]
2 loss= 40.109256867447264 b= 16.833174 w= [[-2.3425255 ]
 [ 5.830906  ]
 [-1.8972093 ]
 [ 4.3102064 ]
 [-0.82777905]
 [17.204485  ]
 [ 2.5758393 ]
 [ 3.112676  ]
 [-1.6574156 ]
 [-3.3587508 ]
 [-2.570733  ]
 [-9.6232815 ]]
3 loss= 33.37962808582607 b= 17.26512 w= [[ -2.6117122 ]
 [  4.702952  ]
 [ -1.5778036 ]
 [  4.31275   ]
 [ -0.84097654]
 [ 19.062311  ]
 [  2.6376035 ]
 [  0.8762664 ]
 [  0.1448856 ]
 [ -2.9647636 ]
 [ -4.09335   ]
 [-12.041904  ]]
4 loss= 30.52751716698955 b= 18.42111 w= [[ -3.057558  ]
 [  4.372488  ]
 [ -1.5832667 ]
 [  4.4189677 ]
 [ -1.2397138 ]
 [ 21.005753  ]
 [  2.3919616 ]
 [ -0.41748807]
 [  0.8681938 ]
 [ -3.1650994 ]
 [ -5.0993967 ]
 [-14.148624  ]]
5 loss= 28.237305209339187 b= 18.61689 w= [[ -3.4077117]
 [  3.9043784]
 [ -1.5561852]
 [  4.057337 ]
 [ -1.8111303]
 [ 21.829535 ]
 [  1.9148487]
 [ -1.818912 ]
 [  1.3054136]
 [ -3.5531423]
 [ -6.1306195]
 [-15.612703 ]]
6 loss= 27.60841138797627 b= 19.575703 w= [[ -3.8311076]
 [  3.6436112]
 [ -1.2864188]
 [  4.040816 ]
 [ -2.1008234]
 [ 22.742483 ]
 [  1.9318794]
 [ -2.817526 ]
 [  1.5584313]
 [ -3.8904903]
 [ -6.534545 ]
 [-16.679106 ]]
7 loss= 26.778311626882456 b= 20.66027 w= [[ -4.0647736 ]
 [  3.341697  ]
 [ -0.88955224]
 [  3.9491894 ]
 [ -2.2838523 ]
 [ 23.55179   ]
 [  2.187933  ]
 [ -3.7334871 ]
 [  2.3973184 ]
 [ -3.7033634 ]
 [ -6.4320297 ]
 [-17.208042  ]]
8 loss= 26.168871347260986 b= 20.662035 w= [[ -4.4030304]
 [  2.9998405]
 [ -0.7637937]
 [  3.8426692]
 [ -2.8714566]
 [ 23.533213 ]
 [  1.6610769]
 [ -4.7592487]
 [  2.4713144]
 [ -4.059291 ]
 [ -6.9512887]
 [-17.88937  ]]
9 loss= 25.86864470691593 b= 22.071772 w= [[ -4.5462995 ]
 [  2.870559  ]
 [  0.03270965]
 [  3.4939141 ]
 [ -2.712903  ]
 [ 24.17475   ]
 [  2.329757  ]
 [ -5.5010734 ]
 [  3.4915571 ]
 [ -3.423291  ]
 [ -6.3729496 ]
 [-17.816172  ]]
10 loss= 25.868785807939894 b= 21.74675 w= [[ -4.831974  ]
 [  2.7216978 ]
 [ -0.28731382]
 [  3.4942183 ]
 [ -3.5211987 ]
 [ 23.965183  ]
 [  1.6012467 ]
 [ -6.355208  ]
 [  3.223423  ]
 [ -4.185844  ]
 [ -7.0262756 ]
 [-18.467148  ]]
11 loss= 25.518217036341543 b= 21.920227 w= [[ -5.0973654 ]
 [  2.7938364 ]
 [ -0.36453778]
 [  3.3041055 ]
 [ -4.0375247 ]
 [ 23.79981   ]
 [  1.0695835 ]
 [ -6.9222465 ]
 [  3.3331666 ]
 [ -4.4804873 ]
 [ -7.3956957 ]
 [-18.796824  ]]
12 loss= 25.262159696927906 b= 23.281355 w= [[ -5.1838307 ]
 [  2.8620427 ]
 [  0.13332623]
 [  3.2317355 ]
 [ -3.9457102 ]
 [ 24.258055  ]
 [  1.6694871 ]
 [ -7.2735724 ]
 [  3.971953  ]
 [ -4.145194  ]
 [ -6.9304175 ]
 [-18.66682   ]]
13 loss= 24.788817811919813 b= 22.854319 w= [[ -5.4085164]
 [  2.7665675]
 [ -0.0273534]
 [  3.0274947]
 [ -4.458851 ]
 [ 23.843842 ]
 [  1.108746 ]
 [ -8.029917 ]
 [  4.0051646]
 [ -4.4012046]
 [ -7.462761 ]
 [-19.062525 ]]
14 loss= 24.966205689196496 b= 23.082798 w= [[ -5.6306515 ]
 [  2.7336261 ]
 [  0.10455926]
 [  3.1152127 ]
 [ -4.8148785 ]
 [ 23.59509   ]
 [  1.0018208 ]
 [ -8.614206  ]
 [  4.0146203 ]
 [ -4.5716257 ]
 [ -7.666316  ]
 [-19.099888  ]]
15 loss= 24.954096351262965 b= 23.950819 w= [[ -5.8462806]
 [  2.7787724]
 [  0.2657916]
 [  2.938707 ]
 [ -4.9721975]
 [ 23.750868 ]
 [  1.2840599]
 [ -8.931883 ]
 [  4.0214663]
 [ -4.717285 ]
 [ -7.466294 ]
 [-18.953493 ]]
16 loss= 24.78484824400601 b= 24.300655 w= [[ -6.0326114]
 [  2.9431577]
 [  0.2608992]
 [  3.0867043]
 [ -5.2281265]
 [ 23.720278 ]
 [  1.1337584]
 [ -9.326554 ]
 [  4.119187 ]
 [ -4.8450546]
 [ -7.678265 ]
 [-19.128788 ]]
17 loss= 24.58784702127189 b= 24.457504 w= [[ -6.258282  ]
 [  3.181809  ]
 [  0.08677367]
 [  2.9102962 ]
 [ -5.6705575 ]
 [ 23.565636  ]
 [  0.79270554]
 [ -9.610425  ]
 [  4.2178197 ]
 [ -5.048728  ]
 [ -7.670843  ]
 [-19.24922   ]]
18 loss= 24.343468833133517 b= 24.977665 w= [[ -6.3939505 ]
 [  3.1633966 ]
 [  0.41382116]
 [  3.0172749 ]
 [ -5.614739  ]
 [ 23.640778  ]
 [  1.0990392 ]
 [-10.129015  ]
 [  4.379323  ]
 [ -4.9844966 ]
 [ -7.568953  ]
 [-19.168013  ]]
19 loss= 24.024050213943784 b= 24.828344 w= [[ -6.624196  ]
 [  3.1760473 ]
 [  0.29286736]
 [  3.087022  ]
 [ -5.9015846 ]
 [ 23.298763  ]
 [  0.69470567]
 [-10.531177  ]
 [  4.46199   ]
 [ -5.1743774 ]
 [ -7.7656198 ]
 [-19.33106   ]]
20 loss= 24.16414207434402 b= 25.654043 w= [[ -6.7095275 ]
 [  3.2278545 ]
 [  0.68407625]
 [  3.2290444 ]
 [ -5.679691  ]
 [ 23.469007  ]
 [  1.2268419 ]
 [-10.788722  ]
 [  5.0625076 ]
 [ -4.805988  ]
 [ -7.4073753 ]
 [-19.121384  ]]
21 loss= 24.199917699002565 b= 25.719582 w= [[ -6.7687197]
 [  3.1703448]
 [  0.7019411]
 [  3.277824 ]
 [ -5.8250294]
 [ 23.250439 ]
 [  1.2014583]
 [-11.248115 ]
 [  5.237967 ]
 [ -4.9131827]
 [ -7.5351233]
 [-19.09405  ]]
22 loss= 24.54300719176881 b= 25.511591 w= [[ -6.9940166 ]
 [  3.447194  ]
 [  0.3674598 ]
 [  3.1694403 ]
 [ -6.361351  ]
 [ 22.95447   ]
 [  0.52540785]
 [-11.378509  ]
 [  4.9414825 ]
 [ -5.3464293 ]
 [ -7.9645214 ]
 [-19.341076  ]]
23 loss= 24.277254300862538 b= 26.570023 w= [[ -7.088482 ]
 [  3.582184 ]
 [  0.7227283]
 [  3.144569 ]
 [ -6.224935 ]
 [ 23.142904 ]
 [  1.0730383]
 [-11.420241 ]
 [  5.4498725]
 [ -5.0359516]
 [ -7.3738146]
 [-19.015854 ]]
24 loss= 24.49896739522942 b= 26.291948 w= [[ -7.2987504 ]
 [  3.4624472 ]
 [  0.41665924]
 [  2.9535275 ]
 [ -6.614426  ]
 [ 22.685432  ]
 [  0.77857476]
 [-11.785061  ]
 [  5.05183   ]
 [ -5.605912  ]
 [ -7.7807875 ]
 [-19.09426   ]]
25 loss= 23.717568155121267 b= 26.63324 w= [[ -7.341557 ]
 [  3.4554076]
 [  0.6615652]
 [  2.983157 ]
 [ -6.4153523]
 [ 22.483963 ]
 [  1.0182014]
 [-12.1559   ]
 [  5.7035313]
 [ -5.2447996]
 [ -7.5673304]
 [-18.919548 ]]
26 loss= 23.939388985264692 b= 26.325397 w= [[ -7.5019717 ]
 [  3.5926514 ]
 [  0.2526881 ]
 [  2.717381  ]
 [ -7.0830097 ]
 [ 22.074148  ]
 [  0.41456825]
 [-12.314027  ]
 [  5.282283  ]
 [ -5.8416886 ]
 [ -8.05383   ]
 [-19.161224  ]]
27 loss= 23.777290685442704 b= 26.856434 w= [[ -7.6416907 ]
 [  3.6124773 ]
 [  0.51319224]
 [  3.1316938 ]
 [ -6.93595   ]
 [ 22.263124  ]
 [  0.7176931 ]
 [-12.537288  ]
 [  5.7655964 ]
 [ -5.4712906 ]
 [ -7.941707  ]
 [-19.145279  ]]
28 loss= 23.631128418515562 b= 26.725382 w= [[ -7.785635  ]
 [  3.5178335 ]
 [  0.36090815]
 [  2.8152049 ]
 [ -7.1631565 ]
 [ 21.946201  ]
 [  0.5157557 ]
 [-12.8536005 ]
 [  5.5053983 ]
 [ -5.8891234 ]
 [ -8.309832  ]
 [-19.184326  ]]
29 loss= 23.908104973156505 b= 26.924124 w= [[ -7.9294224 ]
 [  3.7398477 ]
 [  0.17532293]
 [  2.6122315 ]
 [ -7.5240393 ]
 [ 21.884964  ]
 [  0.33375126]
 [-12.842163  ]
 [  5.0657167 ]
 [ -6.251669  ]
 [ -8.3555765 ]
 [-19.22388   ]]
30 loss= 23.81362120306887 b= 27.122396 w= [[ -8.112027  ]
 [  3.7127173 ]
 [  0.21355534]
 [  2.8299606 ]
 [ -7.591119  ]
 [ 21.826796  ]
 [  0.36616555]
 [-13.0393915 ]
 [  4.911243  ]
 [ -6.3986573 ]
 [ -8.378183  ]
 [-19.257751  ]]
31 loss= 23.91165735925535 b= 27.482319 w= [[ -8.275427  ]
 [  3.8033175 ]
 [  0.20660217]
 [  2.722981  ]
 [ -7.6243663 ]
 [ 21.91588   ]
 [  0.4557306 ]
 [-13.198838  ]
 [  5.0420423 ]
 [ -6.3656154 ]
 [ -8.354572  ]
 [-19.307434  ]]
32 loss= 23.729763893810187 b= 27.776697 w= [[ -8.388941  ]
 [  3.7875183 ]
 [  0.34173185]
 [  3.021546  ]
 [ -7.5459666 ]
 [ 21.882875  ]
 [  0.5362012 ]
 [-13.341028  ]
 [  5.1022153 ]
 [ -6.3141212 ]
 [ -8.294261  ]
 [-19.302649  ]]
33 loss= 23.93210337613594 b= 27.705816 w= [[ -8.470409  ]
 [  3.8281534 ]
 [  0.31942174]
 [  3.0838788 ]
 [ -7.6564755 ]
 [ 21.690977  ]
 [  0.38526046]
 [-13.506848  ]
 [  5.476873  ]
 [ -6.147118  ]
 [ -8.4415865 ]
 [-19.342123  ]]
34 loss= 23.956130882535803 b= 28.315298 w= [[ -8.602523  ]
 [  3.9695895 ]
 [  0.43277955]
 [  3.1986775 ]
 [ -7.6763287 ]
 [ 21.885979  ]
 [  0.55347514]
 [-13.468799  ]
 [  5.716297  ]
 [ -6.0979233 ]
 [ -8.169431  ]
 [-19.298613  ]]
35 loss= 23.895252051767724 b= 27.656057 w= [[ -8.708147  ]
 [  3.8282788 ]
 [  0.3087509 ]
 [  2.8008482 ]
 [ -7.8555593 ]
 [ 21.30901   ]
 [  0.14276734]
 [-13.90289   ]
 [  5.718441  ]
 [ -6.2829566 ]
 [ -8.582256  ]
 [-19.470287  ]]
36 loss= 23.84336399920687 b= 28.568417 w= [[ -8.76645   ]
 [  3.956864  ]
 [  0.76592803]
 [  2.7080052 ]
 [ -7.599224  ]
 [ 21.65886   ]
 [  0.876417  ]
 [-13.939942  ]
 [  6.082025  ]
 [ -5.8705688 ]
 [ -8.015892  ]
 [-19.166927  ]]
37 loss= 23.69764786015998 b= 28.311327 w= [[ -8.904669  ]
 [  4.0546665 ]
 [  0.6802229 ]
 [  2.9823747 ]
 [ -7.7717743 ]
 [ 21.451273  ]
 [  0.63232195]
 [-14.114076  ]
 [  6.230099  ]
 [ -5.9489264 ]
 [ -8.204284  ]
 [-19.307913  ]]
38 loss= 23.846219302760133 b= 28.207794 w= [[ -9.014411  ]
 [  4.1633673 ]
 [  0.6045353 ]
 [  2.7855542 ]
 [ -7.884959  ]
 [ 21.199207  ]
 [  0.44440633]
 [-14.263394  ]
 [  6.271814  ]
 [ -6.0188727 ]
 [ -8.398741  ]
 [-19.315546  ]]
39 loss= 23.719658598615425 b= 28.01301 w= [[ -9.13196   ]
 [  4.035389  ]
 [  0.37016144]
 [  2.794646  ]
 [ -8.087522  ]
 [ 20.953165  ]
 [  0.16266954]
 [-14.4535675 ]
 [  6.1606107 ]
 [ -6.2783933 ]
 [ -8.611126  ]
 [-19.470049  ]]
40 loss= 23.744577850567516 b= 28.41003 w= [[ -9.313865  ]
 [  4.2291803 ]
 [  0.21771903]
 [  2.6180503 ]
 [ -8.208547  ]
 [ 21.00484   ]
 [  0.16970852]
 [-14.306049  ]
 [  5.8757725 ]
 [ -6.5236506 ]
 [ -8.631842  ]
 [-19.442938  ]]
41 loss= 23.789856773273858 b= 28.23479 w= [[ -9.404044  ]
 [  4.0497603 ]
 [  0.37828127]
 [  2.8012776 ]
 [ -8.023906  ]
 [ 20.732527  ]
 [  0.42785844]
 [-14.718212  ]
 [  6.043096  ]
 [ -6.389851  ]
 [ -8.833885  ]
 [-19.387613  ]]
42 loss= 23.591188472473288 b= 28.544195 w= [[ -9.4406    ]
 [  4.3528295 ]
 [  0.501258  ]
 [  2.8134701 ]
 [ -8.055523  ]
 [ 20.816895  ]
 [  0.41262794]
 [-14.598408  ]
 [  6.1104765 ]
 [ -6.27096   ]
 [ -8.791094  ]
 [-19.290258  ]]
43 loss= 23.728712544844953 b= 28.975058 w= [[ -9.487825  ]
 [  4.5661535 ]
 [  0.29508656]
 [  2.6473498 ]
 [ -8.31974   ]
 [ 20.872604  ]
 [  0.29868704]
 [-14.376216  ]
 [  5.8642135 ]
 [ -6.5212784 ]
 [ -8.585383  ]
 [-19.352295  ]]
44 loss= 24.229349031845747 b= 28.991873 w= [[ -9.559776  ]
 [  4.499765  ]
 [  0.4281403 ]
 [  2.905336  ]
 [ -8.26619   ]
 [ 20.73468   ]
 [  0.34896335]
 [-14.588172  ]
 [  6.0584283 ]
 [ -6.4117165 ]
 [ -8.637211  ]
 [-19.465109  ]]
45 loss= 23.60830030983954 b= 29.367428 w= [[ -9.605447  ]
 [  4.5040107 ]
 [  0.35686275]
 [  2.8203597 ]
 [ -8.404388  ]
 [ 20.86636   ]
 [  0.49606237]
 [-14.525944  ]
 [  5.9372835 ]
 [ -6.502252  ]
 [ -8.408     ]
 [-19.454254  ]]
46 loss= 23.59571084345467 b= 28.975672 w= [[-9.7023411e+00]
 [ 4.6522818e+00]
 [-1.7735830e-02]
 [ 2.6745691e+00]
 [-8.7605238e+00]
 [ 2.0600052e+01]
 [-5.0147153e-02]
 [-1.4558458e+01]
 [ 5.6684151e+00]
 [-6.9358063e+00]
 [-8.7424183e+00]
 [-1.9694839e+01]]
47 loss= 24.060208425272634 b= 29.167366 w= [[ -9.675343 ]
 [  4.2731056]
 [  0.4336027]
 [  2.7800105]
 [ -8.395587 ]
 [ 20.427214 ]
 [  0.528013 ]
 [-14.917862 ]
 [  6.0850115]
 [ -6.523422 ]
 [ -8.49983  ]
 [-19.446337 ]]
48 loss= 23.650436353654456 b= 29.964926 w= [[ -9.712793 ]
 [  4.602192 ]
 [  0.574651 ]
 [  2.5682425]
 [ -8.307564 ]
 [ 20.782366 ]
 [  0.8435794]
 [-14.672552 ]
 [  6.4928455]
 [ -6.1594067]
 [ -8.072433 ]
 [-19.263617 ]]
49 loss= 23.582301899472608 b= 29.085123 w= [[ -9.689326 ]
 [  4.2148848]
 [  0.5436937]
 [  2.7420552]
 [ -8.336353 ]
 [ 20.218323 ]
 [  0.549164 ]
 [-15.245883 ]
 [  6.282629 ]
 [ -6.322599 ]
 [ -8.518252 ]
 [-19.342865 ]]
50 loss= 23.639518999850992 b= 29.764324 w= [[ -9.768754 ]
 [  4.4293423]
 [  0.5883116]
 [  2.7819643]
 [ -8.234326 ]
 [ 20.567343 ]
 [  0.7660192]
 [-15.049355 ]
 [  6.5149875]
 [ -6.1466665]
 [ -8.195182 ]
 [-19.270245 ]]
51 loss= 23.71245938876773 b= 29.606424 w= [[ -9.826296  ]
 [  4.346314  ]
 [  0.58799434]
 [  3.0323596 ]
 [ -8.231525  ]
 [ 20.41299   ]
 [  0.61824435]
 [-15.26412   ]
 [  6.6527205 ]
 [ -6.109398  ]
 [ -8.357123  ]
 [-19.35337   ]]
52 loss= 23.668690235055088 b= 29.595034 w= [[ -9.915223  ]
 [  4.6425962 ]
 [  0.27625847]
 [  3.04104   ]
 [ -8.537817  ]
 [ 20.422731  ]
 [  0.26069954]
 [-15.053771  ]
 [  6.3508697 ]
 [ -6.4470005 ]
 [ -8.530164  ]
 [-19.65657   ]]
53 loss= 23.59872310017796 b= 29.279581 w= [[ -9.947328  ]
 [  4.3473196 ]
 [  0.30448475]
 [  2.8383472 ]
 [ -8.562999  ]
 [ 20.088476  ]
 [  0.17397411]
 [-15.363393  ]
 [  6.2707396 ]
 [ -6.495034  ]
 [ -8.639795  ]
 [-19.702152  ]]
54 loss= 23.747357573810795 b= 29.29915 w= [[-10.048079  ]
 [  4.472966  ]
 [  0.18393178]
 [  2.7791271 ]
 [ -8.686483  ]
 [ 20.061127  ]
 [  0.05393922]
 [-15.299123  ]
 [  6.0861874 ]
 [ -6.7048936 ]
 [ -8.777768  ]
 [-19.79866   ]]
55 loss= 23.648635245743897 b= 29.982552 w= [[ -9.974158 ]
 [  4.2648497]
 [  0.6418692]
 [  2.9717808]
 [ -8.307544 ]
 [ 20.292475 ]
 [  0.7202618]
 [-15.369567 ]
 [  6.519421 ]
 [ -6.2979274]
 [ -8.123943 ]
 [-19.456457 ]]
56 loss= 23.666022628413412 b= 29.168274 w= [[-9.9876413e+00]
 [ 4.2955313e+00]
 [ 1.8207084e-01]
 [ 2.8772554e+00]
 [-8.6852217e+00]
 [ 1.9837202e+01]
 [ 8.6829439e-03]
 [-1.5539306e+01]
 [ 6.1381755e+00]
 [-6.6924911e+00]
 [-8.7474651e+00]
 [-1.9832142e+01]]
57 loss= 23.746110791891027 b= 29.707878 w= [[-10.007109  ]
 [  4.556312  ]
 [  0.25388458]
 [  2.8431284 ]
 [ -8.66818   ]
 [ 20.076687  ]
 [  0.03581361]
 [-15.318065  ]
 [  6.049129  ]
 [ -6.749953  ]
 [ -8.573651  ]
 [-19.878101  ]]
58 loss= 23.695939787815824 b= 29.82325 w= [[-10.119212  ]
 [  4.398099  ]
 [  0.3634804 ]
 [  2.8718505 ]
 [ -8.451404  ]
 [ 20.034267  ]
 [  0.37851587]
 [-15.524747  ]
 [  6.0325756 ]
 [ -6.729343  ]
 [ -8.660211  ]
 [-19.729319  ]]
59 loss= 23.691398443283997 b= 30.655363 w= [[-10.115741 ]
 [  4.6623173]
 [  0.5443722]
 [  2.916173 ]
 [ -8.316165 ]
 [ 20.51584  ]
 [  0.8443639]
 [-15.319339 ]
 [  6.3805966]
 [ -6.4039392]
 [ -8.260787 ]
 [-19.594378 ]]
60 loss= 23.649459399479557 b= 29.856987 w= [[-10.12715  ]
 [  4.4365053]
 [  0.3391665]
 [  2.7229376]
 [ -8.594829 ]
 [ 20.034399 ]
 [  0.357377 ]
 [-15.667085 ]
 [  6.3578005]
 [ -6.481364 ]
 [ -8.690162 ]
 [-19.771776 ]]
61 loss= 23.87478130684994 b= 29.681602 w= [[-10.252651  ]
 [  4.424874  ]
 [  0.25035647]
 [  2.7324753 ]
 [ -8.695088  ]
 [ 19.833902  ]
 [  0.23033518]
 [-15.796734  ]
 [  6.1426144 ]
 [ -6.70169   ]
 [ -8.914642  ]
 [-19.907454  ]]
62 loss= 23.79018086029011 b= 29.970552 w= [[-10.256704 ]
 [  4.5779953]
 [  0.2761335]
 [  2.685175 ]
 [ -8.659397 ]
 [ 19.920889 ]
 [  0.3499335]
 [-15.652199 ]
 [  6.1930485]
 [ -6.564307 ]
 [ -8.701863 ]
 [-19.846395 ]]
63 loss= 23.263191038173268 b= 30.010157 w= [[-10.377085  ]
 [  4.643523  ]
 [  0.19805771]
 [  2.760369  ]
 [ -8.75578   ]
 [ 19.821062  ]
 [  0.29830068]
 [-15.622896  ]
 [  5.9676576 ]
 [ -6.861938  ]
 [ -8.801681  ]
 [-19.857544  ]]
64 loss= 23.41764867028649 b= 30.838444 w= [[-10.232682  ]
 [  4.6535215 ]
 [  0.6919845 ]
 [  3.1317408 ]
 [ -8.234447  ]
 [ 20.094677  ]
 [  0.91026545]
 [-15.568183  ]
 [  7.0048738 ]
 [ -5.969003  ]
 [ -8.014002  ]
 [-19.484766  ]]
65 loss= 23.873832003482015 b= 30.26932 w= [[-10.318634  ]
 [  4.43888   ]
 [  0.44806314]
 [  3.1818278 ]
 [ -8.395099  ]
 [ 19.795027  ]
 [  0.5976689 ]
 [-15.789118  ]
 [  6.6290708 ]
 [ -6.332474  ]
 [ -8.347793  ]
 [-19.701212  ]]
66 loss= 24.000205842563215 b= 30.45073 w= [[-10.417879  ]
 [  4.678644  ]
 [  0.29329547]
 [  3.3066292 ]
 [ -8.612761  ]
 [ 19.979963  ]
 [  0.50208014]
 [-15.67274   ]
 [  6.3837156 ]
 [ -6.5542035 ]
 [ -8.543468  ]
 [-19.886482  ]]
67 loss= 23.518385875948333 b= 30.076982 w= [[-10.419812  ]
 [  4.559311  ]
 [  0.18867084]
 [  2.9285624 ]
 [ -8.710751  ]
 [ 19.611921  ]
 [  0.38428244]
 [-15.866668  ]
 [  6.2606053 ]
 [ -6.7508583 ]
 [ -8.562232  ]
 [-19.863907  ]]
68 loss= 23.98734475992551 b= 30.02899 w= [[-10.410919  ]
 [  4.634782  ]
 [  0.16647476]
 [  2.8609226 ]
 [ -8.845177  ]
 [ 19.5111    ]
 [  0.19433281]
 [-15.892373  ]
 [  6.237608  ]
 [ -6.724302  ]
 [ -8.663513  ]
 [-19.903997  ]]
69 loss= 23.5673382360321 b= 30.226381 w= [[-10.453963  ]
 [  4.8198028 ]
 [  0.04096318]
 [  2.7989535 ]
 [ -8.898197  ]
 [ 19.560108  ]
 [  0.19232705]
 [-15.802682  ]
 [  6.063442  ]
 [ -6.904139  ]
 [ -8.723757  ]
 [-19.91998   ]]
70 loss= 23.8051287213879 b= 30.341482 w= [[-10.422128  ]
 [  4.858389  ]
 [  0.07599611]
 [  2.7838256 ]
 [ -8.956047  ]
 [ 19.673355  ]
 [  0.23530284]
 [-15.810201  ]
 [  6.1483603 ]
 [ -6.8563256 ]
 [ -8.726707  ]
 [-20.09025   ]]
71 loss= 23.68903994229853 b= 30.490711 w= [[-10.453152  ]
 [  4.762662  ]
 [  0.18221532]
 [  2.533132  ]
 [ -8.906803  ]
 [ 19.716093  ]
 [  0.41668305]
 [-15.842718  ]
 [  6.2608194 ]
 [ -6.787786  ]
 [ -8.572157  ]
 [-20.067327  ]]
72 loss= 23.389888471041452 b= 30.797901 w= [[-10.350053  ]
 [  4.712917  ]
 [  0.5713717 ]
 [  3.0830417 ]
 [ -8.468698  ]
 [ 19.846977  ]
 [  0.89209205]
 [-15.949393  ]
 [  6.9600434 ]
 [ -6.214031  ]
 [ -8.363383  ]
 [-19.88475   ]]
73 loss= 23.860628056960117 b= 30.285366 w= [[-10.375313  ]
 [  4.754908  ]
 [  0.25528598]
 [  2.9652746 ]
 [ -8.749497  ]
 [ 19.528917  ]
 [  0.41238916]
 [-16.021235  ]
 [  6.5971127 ]
 [ -6.553648  ]
 [ -8.791129  ]
 [-20.021088  ]]
74 loss= 23.090950453699485 b= 30.470396 w= [[-10.318074 ]
 [  4.5695724]
 [  0.6560669]
 [  2.9927113]
 [ -8.436361 ]
 [ 19.51948  ]
 [  0.8649979]
 [-16.245523 ]
 [  7.057178 ]
 [ -6.219952 ]
 [ -8.490729 ]
 [-19.825232 ]]
75 loss= 23.01952809375389 b= 31.046824 w= [[-10.247893  ]
 [  4.723563  ]
 [  0.79603475]
 [  3.1685817 ]
 [ -8.324508  ]
 [ 19.87053   ]
 [  1.070241  ]
 [-16.069788  ]
 [  7.3967547 ]
 [ -5.929669  ]
 [ -8.203579  ]
 [-19.809175  ]]
76 loss= 24.29015673457027 b= 30.559025 w= [[-10.283577  ]
 [  4.6170616 ]
 [  0.5702329 ]
 [  3.0360801 ]
 [ -8.649499  ]
 [ 19.58022   ]
 [  0.67999125]
 [-16.193508  ]
 [  6.982552  ]
 [ -6.31064   ]
 [ -8.566511  ]
 [-20.033632  ]]
77 loss= 23.989758409999823 b= 30.705341 w= [[-10.322599  ]
 [  4.62333   ]
 [  0.5777176 ]
 [  2.7605033 ]
 [ -8.66978   ]
 [ 19.55435   ]
 [  0.73240477]
 [-16.107157  ]
 [  6.940585  ]
 [ -6.280623  ]
 [ -8.476288  ]
 [-19.906685  ]]
78 loss= 23.552301443291245 b= 30.320496 w= [[-10.461244  ]
 [  4.713291  ]
 [  0.08562896]
 [  2.517107  ]
 [ -9.1149235 ]
 [ 19.364658  ]
 [  0.19682339]
 [-16.044834  ]
 [  6.1487236 ]
 [ -6.997702  ]
 [ -8.9983425 ]
 [-20.193153  ]]
79 loss= 23.222809708651003 b= 30.778387 w= [[-10.206888 ]
 [  4.419792 ]
 [  0.9049465]
 [  3.054073 ]
 [ -8.420125 ]
 [ 19.495804 ]
 [  1.066116 ]
 [-16.385532 ]
 [  7.3495355]
 [ -5.914481 ]
 [ -8.583677 ]
 [-19.71564  ]]
80 loss= 23.86320886329309 b= 30.652164 w= [[-10.32288   ]
 [  4.6124725 ]
 [  0.6571791 ]
 [  2.8117032 ]
 [ -8.739629  ]
 [ 19.351372  ]
 [  0.73213637]
 [-16.187052  ]
 [  6.928617  ]
 [ -6.3065944 ]
 [ -8.678014  ]
 [-19.780855  ]]
81 loss= 24.079860232976426 b= 30.692284 w= [[-10.419743  ]
 [  4.695102  ]
 [  0.40112168]
 [  3.1137035 ]
 [ -8.912296  ]
 [ 19.406261  ]
 [  0.56276894]
 [-16.038641  ]
 [  6.4507546 ]
 [ -6.7143955 ]
 [ -8.879326  ]
 [-19.95035   ]]
82 loss= 23.47838908809135 b= 30.730337 w= [[-10.328579  ]
 [  4.622147  ]
 [  0.528181  ]
 [  3.092877  ]
 [ -8.862454  ]
 [ 19.426836  ]
 [  0.62643456]
 [-16.14156   ]
 [  6.7348027 ]
 [ -6.496677  ]
 [ -8.774906  ]
 [-19.93163   ]]
83 loss= 23.75595592971989 b= 30.729498 w= [[-10.381256  ]
 [  4.690456  ]
 [  0.46050245]
 [  2.899673  ]
 [ -8.961656  ]
 [ 19.367603  ]
 [  0.56099653]
 [-16.077211  ]
 [  6.5416985 ]
 [ -6.641609  ]
 [ -8.752668  ]
 [-19.889938  ]]
84 loss= 23.758940298675622 b= 30.554546 w= [[-10.453393  ]
 [  4.546927  ]
 [  0.3723951 ]
 [  2.9232585 ]
 [ -9.077426  ]
 [ 19.188137  ]
 [  0.38146675]
 [-16.087423  ]
 [  6.1716123 ]
 [ -6.9220576 ]
 [ -8.785086  ]
 [-19.845886  ]]
85 loss= 23.970651797230726 b= 30.68416 w= [[-10.393451  ]
 [  4.728294  ]
 [  0.3439809 ]
 [  2.9677489 ]
 [ -9.126196  ]
 [ 19.360943  ]
 [  0.32859838]
 [-16.04385   ]
 [  6.4291506 ]
 [ -6.7449064 ]
 [ -8.725371  ]
 [-19.959894  ]]
86 loss= 23.78054229671363 b= 31.069605 w= [[-10.370871  ]
 [  4.7760806 ]
 [  0.4663345 ]
 [  3.0206861 ]
 [ -8.984733  ]
 [ 19.570858  ]
 [  0.50281227]
 [-15.942252  ]
 [  6.922884  ]
 [ -6.369648  ]
 [ -8.501412  ]
 [-19.892601  ]]
87 loss= 23.42589959211476 b= 30.777786 w= [[-10.377745  ]
 [  4.7979975 ]
 [  0.38616782]
 [  3.0657203 ]
 [ -9.022414  ]
 [ 19.456488  ]
 [  0.3288824 ]
 [-16.1065    ]
 [  6.8503747 ]
 [ -6.3999796 ]
 [ -8.734493  ]
 [-19.972857  ]]
88 loss= 23.719298271710166 b= 30.909422 w= [[-10.423462 ]
 [  4.869157 ]
 [  0.3133483]
 [  3.018265 ]
 [ -9.041623 ]
 [ 19.464022 ]
 [  0.4282065]
 [-15.959501 ]
 [  6.5542865]
 [ -6.64562  ]
 [ -8.695729 ]
 [-19.83408  ]]
89 loss= 23.797337676635443 b= 30.355381 w= [[-10.445159  ]
 [  4.537621  ]
 [  0.40825817]
 [  3.0709045 ]
 [ -8.966535  ]
 [ 19.063074  ]
 [  0.30485532]
 [-16.379923  ]
 [  6.711052  ]
 [ -6.5773935 ]
 [ -8.885419  ]
 [-19.81147   ]]
90 loss= 23.44566683681124 b= 30.298635 w= [[-10.398253  ]
 [  4.666264  ]
 [  0.1361543 ]
 [  2.8021405 ]
 [ -9.297876  ]
 [ 19.039791  ]
 [  0.04242021]
 [-16.209705  ]
 [  6.8116655 ]
 [ -6.642736  ]
 [ -8.757426  ]
 [-19.914751  ]]
91 loss= 23.87243340698243 b= 30.431221 w= [[-10.449261  ]
 [  4.773179  ]
 [  0.11520519]
 [  2.8141637 ]
 [ -9.364431  ]
 [ 19.122204  ]
 [  0.02373883]
 [-16.123463  ]
 [  6.578949  ]
 [ -6.798057  ]
 [ -8.847852  ]
 [-19.94857   ]]
92 loss= 23.762410563531333 b= 30.708416 w= [[-10.391717 ]
 [  4.687369 ]
 [  0.3765069]
 [  2.8064482]
 [ -9.121766 ]
 [ 19.207445 ]
 [  0.3472685]
 [-16.187088 ]
 [  6.9800324]
 [ -6.527897 ]
 [ -8.635248 ]
 [-19.730564 ]]
93 loss= 23.40170673281533 b= 30.651705 w= [[-10.52945   ]
 [  4.824846  ]
 [  0.13238972]
 [  2.7245955 ]
 [ -9.413962  ]
 [ 19.294641  ]
 [  0.05631711]
 [-16.019503  ]
 [  6.2883306 ]
 [ -7.033646  ]
 [ -8.861289  ]
 [-20.010357  ]]
94 loss= 23.832656126318533 b= 30.50901 w= [[-10.541353  ]
 [  4.6726546 ]
 [  0.25462288]
 [  2.7275655 ]
 [ -9.280176  ]
 [ 19.15651   ]
 [  0.1429085 ]
 [-16.181194  ]
 [  6.5369053 ]
 [ -6.7969193 ]
 [ -8.772801  ]
 [-19.989119  ]]
95 loss= 23.511791958233925 b= 30.651087 w= [[-10.527801  ]
 [  4.6971164 ]
 [  0.19680677]
 [  2.6984658 ]
 [ -9.358892  ]
 [ 19.287226  ]
 [  0.13754722]
 [-16.106567  ]
 [  6.3271775 ]
 [ -7.008725  ]
 [ -8.792334  ]
 [-19.949974  ]]
96 loss= 23.618108268194803 b= 30.6647 w= [[-10.522314  ]
 [  4.7287393 ]
 [  0.24817628]
 [  2.8791585 ]
 [ -9.246429  ]
 [ 19.308891  ]
 [  0.15438616]
 [-16.171095  ]
 [  6.505141  ]
 [ -6.8498654 ]
 [ -8.787869  ]
 [-20.05855   ]]
97 loss= 23.47316054647413 b= 30.478718 w= [[-10.53359   ]
 [  4.7159495 ]
 [  0.25373352]
 [  2.736828  ]
 [ -9.196941  ]
 [ 19.185278  ]
 [  0.12525348]
 [-16.296206  ]
 [  6.722521  ]
 [ -6.6965632 ]
 [ -8.777827  ]
 [-20.042671  ]]
98 loss= 23.401987678905112 b= 31.00851 w= [[-10.608071  ]
 [  4.9980717 ]
 [  0.15268484]
 [  2.8047147 ]
 [ -9.159167  ]
 [ 19.58358   ]
 [  0.16270953]
 [-15.958218  ]
 [  6.740722  ]
 [ -6.7140284 ]
 [ -8.689971  ]
 [-20.164894  ]]
99 loss= 23.478625298478565 b= 30.913446 w= [[-10.577047  ]
 [  4.7054267 ]
 [  0.36446163]
 [  2.8717806 ]
 [ -8.9971075 ]
 [ 19.34629   ]
 [  0.23750088]
 [-16.148403  ]
 [  6.856062  ]
 [ -6.609274  ]
 [ -8.653079  ]
 [-19.94515   ]]
100 loss= 23.71663660745805 b= 31.190605 w= [[-10.589167  ]
 [  4.6123533 ]
 [  0.5464035 ]
 [  2.9526188 ]
 [ -8.831693  ]
 [ 19.462164  ]
 [  0.56038535]
 [-16.15626   ]
 [  6.81912   ]
 [ -6.6436763 ]
 [ -8.4910755 ]
 [-19.802721  ]]
n=np.random.randint(506)
print(n)
x_test = x_d[n]

x_test = x_test.reshape(1,12)
predict = sess.run(pred,feed_dict={x:x_test})
print("pred=%f" % predict)
tar=y_d[n]
print("yuanlai=%f" % tar)
156
pred=43.752884
yuanlai=50.000000
最后修改:2019 年 07 月 28 日 12 : 03 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论

© 2018-2019 Copyright   | 浙ICP备18047860号-1| SiteMap