Last active
April 8, 2017 11:01
-
-
Save Santara/1740be56e9f7198fe908e4327dd2a7b9 to your computer and use it in GitHub Desktop.
Multi-network tensorflow trial
This file contains 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
import tensorflow as tf | |
import numpy as np | |
inputs1 = tf.placeholder(shape=[1,16],dtype=tf.float32) | |
W = tf.Variable(tf.random_uniform([16,4],0,0.01)) | |
Qout = tf.matmul(inputs1,W) | |
grad_Qout_inputs1 = tf.gradients(Qout, inputs1) | |
init = tf.initialize_all_variables() | |
sess = tf.Session() | |
sess.run(init) | |
inp = np.random.random([1,16]) | |
grad_Qout_inputs1_val = sess.run([grad_Qout_inputs1], feed_dict={inputs1:inp}) | |
print grad_Qout_inputs1_val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this
import tensorflow as tf
import numpy as np
inputs1 = tf.placeholder(shape=[1,16],dtype=tf.float32)
W = tf.Variable(tf.random_uniform([16,4],0,0.01))
Qout = tf.matmul(inputs1,W)
grad_Qout_inputs1 = tf.gradients(Qout, inputs1)
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
inp = np.random.random([1,16])
grad_Qout_inputs1_val = sess.run([grad_Qout_inputs1], feed_dict={inputs1:inp})
print grad_Qout_inputs1_val