<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Constants_Sequences_and_Random_Values
Step1:  NOTE on notation
* _x, _y, _z, ...
Step2:  Q2. Let X be a tensor of [[1,2,3], [4,5,6]]. <br />Create a tensor of the same shape and dtype as X with all elements set to zero.
Step3:  Q3. Create a tensor of shape [2, 3] with all elements set to one.
Step4:  Q4. Let X be a tensor of [[1,2,3], [4,5,6]]. <br />Create a tensor of the same shape and dtype as X with all elements set to one.
Step5:  Q5. Create a tensor of the shape [3, 2], with all elements of 5.
Step6:  Q6. Create a constant tensor of [[1, 3, 5], [4, 6, 8]], with dtype=float32
Step7:  Q7. Create a constant tensor of the shape [2, 3], with all elements set to 4.
Step8:  Sequences
Q8. Create a 1-D tensor of 50 evenly spaced elements between 5 and 10 inclusive.
Step9:  Q9. Create a tensor which looks like [10, 12, 14, 16, ..., 100].
Step10:  Random Tensors
Q10. Create a random tensor of the shape [3, 2], with elements from a normal distribution of mean=0, standard deviation=2.
Step11:  Q11. Create a random tensor of the shape [3, 2], with elements from a normal distribution of mean=0, standard deviation=1 such that any values don't exceed 2 standard deviations from the mean.
Step12:  Q12. Create a random tensor of the shape [3, 2], with all elements from a uniform distribution that ranges from 0 to 2 (exclusive).
Step13:  Q13. Let X be a tensor of [[1, 2], [3, 4], [5, 6]]. Shuffle X along its first dimension.
Step14:  Q14. Let X be a random tensor of the shape [10, 10, 3], with elements from a unit normal distribution. Crop X with the shape of [5, 5, 3].
<ASSISTANT_TASK:>
Python Code:
from __future__ import print_function
import tensorflow as tf
import numpy as np
from datetime import date
date.today()
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
tf.__version__
np.__version__
sess = tf.InteractiveSession()
Explanation: Constants_Sequences_and_Random_Values
End of explanation
out = tf.zeros([2, 3])
print(out.eval())
assert np.allclose(out.eval(), np.zeros([2, 3]))
# tf.zeros == np.zeros 
Explanation: NOTE on notation
* _x, _y, _z, ...: NumPy 0-d or 1-d arrays
* _X, _Y, _Z, ...: NumPy 2-d or higer dimensional arrays
* x, y, z, ...: 0-d or 1-d tensors
* X, Y, Z, ...: 2-d or higher dimensional tensors
Constant Value Tensors
Q1. Create a tensor of the shape [2, 3] with all elements set to zero.
End of explanation
_X = np.array([[1,2,3], [4,5,6]])
X = tf.convert_to_tensor(_X)
out = tf.zeros_like(X)
print(out.eval())
assert np.allclose(out.eval(), np.zeros_like(_X))
# tf.zeros_like == np.zeros_like
Explanation: Q2. Let X be a tensor of [[1,2,3], [4,5,6]]. <br />Create a tensor of the same shape and dtype as X with all elements set to zero.
End of explanation
out = tf.ones([2, 3])
print(out.eval())
assert np.allclose(out.eval(), np.ones([2, 3]))
# tf.ones == np.ones
Explanation: Q3. Create a tensor of shape [2, 3] with all elements set to one.
End of explanation
_X = np.array([[1,2,3], [4,5,6]])
X = tf.convert_to_tensor(_X)
out = tf.ones_like(X)
print(out.eval())
assert np.allclose(out.eval(), np.ones_like(_X))
# tf.ones_like == np.ones_like
Explanation: Q4. Let X be a tensor of [[1,2,3], [4,5,6]]. <br />Create a tensor of the same shape and dtype as X with all elements set to one.
End of explanation
out1 = tf.fill([3, 2], 5)
out2 = tf.ones([3, 2]) * 5
out3 = tf.constant(5, shape=[3, 2])
assert np.allclose(out1.eval(), out2.eval())
assert np.allclose(out1.eval(), out3.eval())
assert np.allclose(out1.eval(), np.full([3, 2], 5))
print(out1.eval())
Explanation: Q5. Create a tensor of the shape [3, 2], with all elements of 5.
End of explanation
out = tf.constant([[1, 3, 5], [4, 6, 8]], dtype=tf.float32)
print(out.eval())
assert np.allclose(out.eval(), np.array([[1, 3, 5], [4, 6, 8]], dtype=np.float32))
Explanation: Q6. Create a constant tensor of [[1, 3, 5], [4, 6, 8]], with dtype=float32
End of explanation
out = tf.constant(4, shape=[2, 3])
print(out.eval())
assert np.allclose(out.eval(), np.full([2, 3], 4))
Explanation: Q7. Create a constant tensor of the shape [2, 3], with all elements set to 4.
End of explanation
out = tf.linspace(5., 10., 50)
print(out.eval())
assert np.allclose(out.eval(), np.linspace(5., 10., 50))
# tf.linspace == np.linspace
Explanation: Sequences
Q8. Create a 1-D tensor of 50 evenly spaced elements between 5 and 10 inclusive.
End of explanation
out = tf.range(10, 101, 2)
print(out.eval())
assert np.allclose(out.eval(), np.arange(10, 101, 2))
# tf.range == np.arange
# Note that the end is exlcuded unlike tf.linspace
Explanation: Q9. Create a tensor which looks like [10, 12, 14, 16, ..., 100].
End of explanation
X = tf.random_normal([3, 2], 0, 2.)
print(X.eval())
# tf.random_normal is almost equivalent to np.random.normal
# But the order of the arguments is differnt.
# _X = np.random.normal(0, 2., [3, 2])
Explanation: Random Tensors
Q10. Create a random tensor of the shape [3, 2], with elements from a normal distribution of mean=0, standard deviation=2.
End of explanation
out = tf.truncated_normal([3, 2])
print(out.eval())
Explanation: Q11. Create a random tensor of the shape [3, 2], with elements from a normal distribution of mean=0, standard deviation=1 such that any values don't exceed 2 standard deviations from the mean.
End of explanation
out = tf.random_uniform([3, 2], 0, 2)
print(out.eval())
# tf.random_uniform is almost equivalent to np.random.uniform
# But the order of the arguments is differnt.
# _X = np.random.uniform(0, 2., [3, 2])
Explanation: Q12. Create a random tensor of the shape [3, 2], with all elements from a uniform distribution that ranges from 0 to 2 (exclusive).
End of explanation
_X = np.array([[1, 2], [3, 4], [5, 6]])
X = tf.constant(_X)
out = tf.random_shuffle(X)
print(out.eval())
# tf.random_shuffle() is not a in-place function unlike np.random_shuffle().
# np.random.shuffle(_X)
# print(_X)
Explanation: Q13. Let X be a tensor of [[1, 2], [3, 4], [5, 6]]. Shuffle X along its first dimension.
End of explanation
X = tf.random_normal([10, 10, 3])
out = tf.random_crop(X, [5, 5, 3])
print(out.eval())
Explanation: Q14. Let X be a random tensor of the shape [10, 10, 3], with elements from a unit normal distribution. Crop X with the shape of [5, 5, 3].
End of explanation
<END_TASK>