Skip to content

Instantly share code, notes, and snippets.

@ispamm
Last active March 7, 2018 11:44
Show Gist options
  • Save ispamm/6bd345143de9082685dc287aec03039d to your computer and use it in GitHub Desktop.
Save ispamm/6bd345143de9082685dc287aec03039d to your computer and use it in GitHub Desktop.
# Create a variable
W = tfe.Variable(0.5, name='w')
# Print the value
print(W) # Prints: <tf.Variable 'w:0' shape=() dtype=float32, numpy=0.5>
# Add a NumPy array and print
print(W + np.asarray([1, 3])) # Prints: tf.Tensor([1.5 3.5], shape=(2,), dtype=float32)
# Get the value in NumPy form
print(W.numpy()) # Prints: 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment