TensorFlow for machine learning 基本模板
2017-10-07 16:56
525 查看
TensorFlow for machine learning 基本模板
import tensorflow as tf import os #paramates W = tf.Variable(tf.zeros([5,1]),name = 'weight') b = tf.Variable(0,name = 'bias') def combine_inputs(X): return tf.mul(X,W)+b # forward propagation def inference(X): return tf.sigmoid(combine_inputs(X)) # cost function def loss(X,Y): return tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(combine_inputs(X) , Y) ) def train(total_loss) learning_rate = 0.00001 return tf.train.GraidentDescendOptimizer(learning_rate).minimize(total_loss) def evaluate(X): return tf.cast(interence(X)>0.5 , tf.float32) With tf.Session() as sess: tf.initial_all_variables().run() X,Y = inputs() total_loss = loss(X,Y) train_op = train(total_loss) coord = tf.train.Coordinator() threads = tf.train_start_queue_runners(sess = sess ,coord = coord) #actual training loop training_step = 1000 for step in range(training_step): sess.run([train_op]) evaluate(X,Y)
相关文章推荐
- Machine Learning with Scikit-Learn and Tensorflow 7 集成学习和随机森林(章节目录)
- 【deeplearning.ai笔记第二课】1.3 机器学习基本方法(Basic recipe for machine learning)
- Machine Learning with Scikit-Learn and Tensorflow 7.3 Out-of-Bag评价方式
- TensorLayer : The Fastest Deep Learning Library for TensorFlow
- Machine Learning with Scikit-Learn and Tensorflow 6.4 CART算法
- Machine Learning with Scikit-Learn and Tensorflow 6 决策树(章节目录)
- Machine Learning with Scikit-Learn and Tensorflow 7.4 Random Patches和Random Subspaces
- 翻译 | Keras : Deep Learning library for Tensorflow and Theano
- chapter2 of OReilly.Hands-On.Machine.Learning.with.Scikit-Learn.and.TensorFlow
- Deep Learning for Chatbots, Part 2 – Implementing a Retrieval-Based Model in Tensorflow
- <TensorFlow Machine Learning Cookbook>学习笔记(1.2)
- Machine Learning with Scikit-Learn and Tensorflow 6.9 决策树局限性
- Machine Learning with Scikit-Learn and Tensorflow 7.7 特征重要程度
- <TensorFlow Machine Learning Cookbook>学习笔记(1.4)
- TensorFlow Estimators: Managing Simplicity vs. Flexibility in High-Level Machine Learning Frameworks
- 《Hands-on Machine Learning with Scikit-Learn and TensorFlow》 读书笔记
- Machine Learning with Scikit-Learn and Tensorflow 7.5 随机森林
- 斯坦福课程“CS 20SI:TensorFlow for Deep Learning Research”中文讲义(1)
- Machine Learning with Scikit-Learn and Tensorflow 7.10 Stacking
- 《Hands-on Machine Learning with Scikit-Learn and TensorFlow》 读书笔记