基于tensorflow
yfml的Python项目详细描述
some simple functions based on tensorflow
#####################
Simple Example here
#####################
import tensorflow as tf
from yfml.layers import *
from yfml.train import *
from yfml.utils import *
from yfml.quick_build import *
from tensorflow.examples.tutorials.mnist import 输入数据
>mnist=输入数据。读取数据集('mnist数据,one-hot=true)
train数据,train-label=mnist.train.train.下一批(50000)
training数据=数据(train数据,train-label)
>x=fl持有人([none,784])
>y=fl持有人([none,10])
>如果training=bool持有人([none,10,10,10,10,10,10,10,10,10,10,10,10;如果training=bool持有人(
>x=x重塑持有人([n,10,10,10,10,10(X,[-1,28,28,1])
final=mix嫒stack('stack',x嫒,types=['conv2d','maxpool2d','conv2d','maxpool2d','fc',,
shapes=[16,2,32,2,256,10],use嫒batch嫒norm=false,if嫒training=if嫒training,
activation嫒relu,last嫒activation嫒fn=softmax')
loss=loss嫒优化器='adam',正则化器=['l2',0.001])
精度=计算精度(final,y)
sess=tf.session()
sess.run(tf.global_variables_initializer())
对于i in range(1000):
training_data.shuffle()
iter=50000//100
avg_acc=0。
对于j in range(iter):
xs ys=training_data.下一批(100)
acc,=sess.run([精度,opt],{x:xs,y:ys,if_training:true})
avg_acc+=acc/iter
print('精度为',avg_acc)
#####################
Simple Example here
#####################
import tensorflow as tf
from yfml.layers import *
from yfml.train import *
from yfml.utils import *
from yfml.quick_build import *
from tensorflow.examples.tutorials.mnist import 输入数据
>mnist=输入数据。读取数据集('mnist数据,one-hot=true)
train数据,train-label=mnist.train.train.下一批(50000)
training数据=数据(train数据,train-label)
>x=fl持有人([none,784])
>y=fl持有人([none,10])
>如果training=bool持有人([none,10,10,10,10,10,10,10,10,10,10,10,10;如果training=bool持有人(
>x=x重塑持有人([n,10,10,10,10,10(X,[-1,28,28,1])
final=mix嫒stack('stack',x嫒,types=['conv2d','maxpool2d','conv2d','maxpool2d','fc',,
shapes=[16,2,32,2,256,10],use嫒batch嫒norm=false,if嫒training=if嫒training,
activation嫒relu,last嫒activation嫒fn=softmax')
loss=loss嫒优化器='adam',正则化器=['l2',0.001])
精度=计算精度(final,y)
sess=tf.session()
sess.run(tf.global_variables_initializer())
对于i in range(1000):
training_data.shuffle()
iter=50000//100
avg_acc=0。
对于j in range(iter):
xs ys=training_data.下一批(100)
acc,=sess.run([精度,opt],{x:xs,y:ys,if_training:true})
avg_acc+=acc/iter
print('精度为',avg_acc)