Python3.6:print 語法錯誤
阿新 • • 發佈:2018-12-22
print 語法錯誤
print step, sess.run(W), sess.run(b)
錯誤原因:
python2.7 print 'hello '
python3及以上 print('hello')
因此,修改為:
print (step, sess.run(W), sess.run(b))
即可,結果:
0 [[ 0.91210413 -0.04129256]] [ 0.04484042] 20 [[ 0.28546557 0.23647967]] [ 0.19098906] 40 [[ 0.15442868 0.23037918]] [ 0.25790811] 60 [[ 0.11846238 0.21355666]] [ 0.28405273] 80 [[ 0.10667393 0.20536564]] [ 0.29399648] 100 [[ 0.10247139 0.20204933]] [ 0.29774484] 120 [[ 0.10092307 0.20077361]] [ 0.29915351] 140 [[ 0.10034581 0.20029087]] [ 0.29968235] 160 [[ 0.10012968 0.20010923]] [ 0.2998808] 180 [[ 0.10004867 0.200041 ]] [ 0.29995525] 200 [[ 0.10001829 0.20001541]] [ 0.2999832]