import tensorflow as tf
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
#load data
digits = load_digits()
X = digits.data
y = digits.target
y = LabelBinarizer().fit_transform(y)
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=.3)
def add_layer(inputs,in_size,out_size,layer_name,activation_function=None):
#add one more layer and return the out of this layer
with tf.name_scope('layer'):
with tf.name_scope('Wieght'):
Weight = tf.Variable(tf.random_normal([in_size,out_size]),name='W')
with tf.name_scope('biases'):
biases = tf.Variable(tf.zeros([1,out_size]) + 0.1,name='biases')
with tf.name_scope('Wx_plus_b'):
Wx_plus_b = tf.add(tf.matmul(inputs,Weight),biases,name='Wx_plus_b')
Wx_
tensorflow--代码学习4(dropout)
最新推荐文章于 2022-12-26 18:09:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)