| 2 | 1/1 | 返回列表 |
| 查看: 789 | 回復(fù): 1 | ||
qcl龍銅蟲 (初入文壇)
|
[求助]
tensorflow神經(jīng)網(wǎng)絡(luò)問題請教 已有1人參與
|
|
請教下,我這段tensorflow代碼誤差一直收斂不了是為什么 import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, activation_function=None): Weights = tf.Variable(tf.random_normal([in_size, out_size])) biases = tf.Variable(tf.zeros([1, out_size]) + 0.1) Wx_plus_b = tf.matmul(inputs, Weights) + biases if activation_function is None: outputs = Wx_plus_b else: outputs = activation_function(Wx_plus_b) return outputs # Make up some real data x_data = np.linspace(0.2, 13, 33)[:, np.newaxis] noise = np.random.normal(0, 0.05, x_data.shape) y_data = 2 * x_data + 2.2 + noise # define placeholder for inputs to network xs = tf.placeholder(tf.float32, [None, 1]) ys = tf.placeholder(tf.float32, [None, 1]) # add hidden layer l1 = add_layer(xs, 1, 10, activation_function=tf.nn.relu) # add output layer prediction = add_layer(l1, 10, 1, activation_function=None) # the error between prediciton and real data loss = tf.reduce_mean(tf.reduce_sum(tf.square( ys -prediction), reduction_indices=[1])) train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss) # important step init = tf.global_variables_initializer() sess= tf.Session() sess.run(init) for i in range(10000): # training sess.run(train_step, feed_dict={xs: x_data, ys: y_data}) if i % 50 == 0: # to see the step improvement print(sess.run(loss, feed_dict={xs: x_data, ys: y_data})) |
鐵桿木蟲 (正式寫手)
| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 材料調(diào)劑 +12 | 一樣YWY 2026-04-01 | 12/600 |
|
|---|---|---|---|---|
|
[考研] 一志愿安徽大學(xué)計算機科學(xué)與技術(shù)學(xué)碩,331分求調(diào)劑 +3 | 蔣昌鵬qtj 2026-04-01 | 3/150 |
|
|
[考研] 291求調(diào)劑 +20 | Y-cap 2026-03-29 | 25/1250 |
|
|
[考研] 292分,材料與化工,申請調(diào)劑 +18 | 程晴之 2026-04-01 | 20/1000 |
|
|
[考研] 311求調(diào)劑 +13 | zchqwer 2026-04-01 | 15/750 |
|
|
[考研] 275求調(diào)劑 +12 | waltzh 2026-04-01 | 12/600 |
|
|
[考研] 292求調(diào)劑 +17 | 木蟲er12138 2026-04-01 | 17/850 |
|
|
[考研] 食品學(xué)碩362求調(diào)劑 +3 | xuanxianxian 2026-04-01 | 3/150 |
|
|
[考研] 070300化學(xué)專業(yè)279調(diào)劑 +10 | 哈哈哈^_^ 2026-03-31 | 10/500 |
|
|
[考研] 合肥區(qū)域性重點一本招收調(diào)劑 +4 | 6266jl 2026-03-30 | 8/400 |
|
|
[考研] 求調(diào)劑 +9 | akdhjs 2026-03-31 | 10/500 |
|
|
[考博] 材料專業(yè)申博 +5 | 杜雨婷dyt 2026-03-29 | 5/250 |
|
|
[考研] 總分322求生物學(xué)/生化與分子/生物信息學(xué)相關(guān)調(diào)劑 +6 | 星沉uu 2026-03-26 | 7/350 |
|
|
[考研] 抱歉 +4 | 田洪有 2026-03-30 | 4/200 |
|
|
[考研] 303求調(diào)劑 +7 | DLkz1314. 2026-03-30 | 7/350 |
|
|
[考研] 081200-314 +3 | LILIQQ 2026-03-27 | 4/200 |
|
|
[考研] 352分 化工與材料 +5 | 海納百川Ly 2026-03-27 | 5/250 |
|
|
[考研] 330一志愿中國海洋大學(xué) 化學(xué)工程 085602 有讀博意愿 求調(diào)劑 +3 | wywy.. 2026-03-27 | 4/200 |
|
|
[考研] 一志愿吉大071010,316分求調(diào)劑 +3 | xgbiknn 2026-03-27 | 3/150 |
|
|
[考研] 324求調(diào)劑 +5 | hanamiko 2026-03-26 | 5/250 |
|