Last active
July 17, 2018 13:34
-
-
Save risenW/8b75fd0a47770132c5910e2e7c060710 to your computer and use it in GitHub Desktop.
Code for batch training using tensorflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load our libraries | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import tensorflow as tf | |
sess = tf.Session() | |
# declare batch size | |
batch_size = 20 | |
x_vals = np.random.normal(1, 0.1, 100) | |
y_vals = np.repeat(10., 100) | |
X_data = tf.placeholder(shape=[None, 1], dtype=tf.float32) | |
Y_target = tf.placeholder(shape=[None, 1], dtype=tf.float32) | |
W = tf.Variable(tf.constant(0., shape=[1,1])) #It is good practice to initialize the weight to zero | |
#Add our simple operation to the computational graph | |
Y_pred = tf.matmul(X_data, W) | |
# initialize our variables | |
init = tf.global_variables_initializer() | |
sess.run(init) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment