import tensorflow as tf
import numpy as np
import os
#输入数据
x_data = np.linspace(-1,1,300)[:, np.newaxis]
noise = np.random.normal(0,0.05, x_data.shape)
y_data = np.square(x_data)-0.5+noise
#输入层
with tf.name_scope('input_layer'): #输入层。将这两个变量放到input_layer作用域下,tensorboard会把他们放在一个图形里面
xs = tf.placeholder(tf.float32, [None, 1], name = 'x_input') # xs起名x_input,会在图形上显示
ys = tf.placeholder(tf.float32, [None, 1], name = 'y_input') # ys起名y_input,会在图形上显示
#隐层
with tf.name_scope('hidden_layer'): #隐层。将隐层权重、偏置、净输入放在一起
with tf.name_scope('weight'): #权重
W1 = tf.Variable(tf.random_normal([1,10]))
tf.summary.histogram('hidden_layer/weight', W1)
with tf.name_scope('bias'): #偏置
b1 = tf.Variable(tf.zeros([1,10])+0.1)
tf.summary.histogram('hidden_layer/bias', b1)
with tf.name_
Tensorflow模型保存与读取
最新推荐文章于 2020-04-12 00:05:21 发布