| ²é¿´: 784 | »Ø¸´: 1 | ||
qclýˆÍ³æ (³õÈëÎÄ̳)
|
[ÇóÖú]
tensorflowÉñ¾ÍøÂçÎÊÌâÇë½Ì ÒÑÓÐ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})) |
» ²ÂÄãϲ»¶
0703»¯Ñ§µ÷¼Á
ÒѾÓÐ12È˻ظ´
0703»¯Ñ§ 305Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
0703»¯Ñ§µ÷¼Á£¬Çó¸÷λÀÏʦÊÕÁô
ÒѾÓÐ10È˻ظ´
271²ÄÁϹ¤³ÌÇóµ÷¼Á
ÒѾÓÐ5È˻ظ´
281Çóµ÷¼Á£¨0805£©
ÒѾÓÐ16È˻ظ´
304Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
²ÄÁϹ¤³Ìר˶µ÷¼Á
ÒѾÓÐ6È˻ظ´
Ò»Ö¾Ô¸Ìì´ó²ÄÁÏÓ뻯¹¤£¨085600£©×Ü·Ö338
ÒѾÓÐ4È˻ظ´
085700×ÊÔ´Óë»·¾³308Çóµ÷¼Á
ÒѾÓÐ3È˻ظ´
Çó²ÄÁϵ÷¼Á
ÒѾÓÐ8È˻ظ´
ÀÁÇàÍÜÍÂÅÝÅÝ
Ìú¸Ëľ³æ (ÕýʽдÊÖ)
- Ó¦Öú: 3 (Ó×¶ùÔ°)
- ½ð±Ò: 5291
- Ìû×Ó: 483
- ÔÚÏß: 184Сʱ
- ³æºÅ: 2245571
- ×¢²á: 2013-01-17
- ÐÔ±ð: GG
- רҵ: ·ÇÏßÐÔ¹âѧÓëÁ¿×Ó¹âѧ
2Â¥2018-11-04 10:56:02













»Ø¸´´ËÂ¥