<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Tensor Transformations
Step1:  NOTE on notation
* _x, _y, _z, ...
Step2:  Q23. Given X below, reverse the last dimension.
Step3:  Q24. Given X below, permute its dimensions such that the new tensor has shape (3, 1, 2).
Step4:  Q25. Given X, below, get the first, and third rows.
Step5:  Q26. Given X below, get the elements 5 and 7.
<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: Tensor Transformations
End of explanation
X = tf.constant(
[[[0, 0, 1],
  [0, 1, 0],
  [0, 0, 0]],
 
 [[0, 0, 1],
  [0, 1, 0],
  [1, 0, 0]]])
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
Casting
Q1. Let X be a tensor of [["1.1", "2.2"], ["3.3", "4.4"]]. Convert the datatype of X to float32.
Q2. Let X be a tensor [[1, 2], [3, 4]] of int32. Convert the data type of X to float64.
Q3. Let X be a tensor [[1, 2], [3, 4]] of int32. Convert the data type of X to float32.
Q4. Let X be a tensor [[1, 2], [3, 4]] of float32. Convert the data type of X to int32.
Q5. Let X be a tensor [[1, 2], [3, 4]] of float32. Convert the data type of X to int64.
Shapes and Shaping
Q6. Let X be a tensor of [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]. Create a tensor representing the shape of X.
Q7. Let X be a tensor of [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]) and y be a tensor [10, 20]. Create a list of tensors representing the shape of X and y.
Q8. Let X be a tensor of [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]. Create a tensor representing the size (=total number of elements) of X.
Q9. Let X be a tensor of [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]. Create a tensor representing the rank (=number of dimensions) of X.
Q10. Let X be tf.ones([10, 10, 3]). Reshape X so that the size of the second dimension equals 150.
Q11. Let X be tf.ones([10, 10, 1, 1]). Remove all the dimensions of size 1 in X.
Q12. Let X be tf.ones([10, 10, 1, 1]). Remove only the third dimension in X.
Q13. Let X be tf.ones([10, 10]). Add a dimension of 1 at the end of X.
Slicing and Joining
Q14. Let X be a tensor<br/>
[[[1, 1, 1], [2, 2, 2]],<br/>
[[3, 3, 3], [4, 4, 4]],<br/>
[[5, 5, 5], [6, 6, 6]]].<br/>
Extract the [[[3, 3, 3], [5, 5, 5]] from X.
Q15. Let X be a tensor of<br/>
[[ 1  2]<br />
 [ 3  4]<br />
 [ 5  6]<br />
 [ 7  8]<br />
 [ 9 10]].<br />
 Extract the [[1, 2], [5, 6], [9, 10]]] from X.
Q16. Let X be a tensor of<br/>
[[ 1  2  3  4  5]<br />
 [ 6  7  8  9  10]].<br />
Split X into 5 same-sized tensors along the second dimension.
Q17. Lex X be a tensor<br/>
[[ 1 2 3]<br/>
 [ 4 5 6].<br/>
Create a tensor looking like <br/>
[[ 1 2 3 1 2 3 1 2 3 ]<br/>
 [ 4 5 6 4 5 6 4 5 6 ]].
Q18. Lex X be a tensor <br/>
[[ 1 2 3]<br/>
 [ 4 5 6].<br/>
Pad 2 * 0's before the first dimension, 3 * 0's after the second dimension.
Q19. Lex X be a tensor <br/>
[[ 1 2 3]<br/>
 [ 4 5 6].<br/>
and Y be a tensor<br/>
[[ 7 8 9]<br/>
 [10 11 12]].<br/>
Concatenate X and Y so that the new tensor looks like [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]].
Q20. Let x, y, and z be tensors [1, 4], [2, 5], and [3, 6], respectively. <br/>Create a single tensor from these such that it looks [[1, 2, 3], [4, 5, 6]].
Q21. Let X be a tensor [[1, 2, 3], [4, 5, 6]]. Convert X into Y such that Y looks like [[1, 4], [2, 5], [3, 6]].
Q22. Given X below, reverse the sequence along the second axis except the zero-paddings.
End of explanation
_X = np.arange(1, 1*2*3*4 + 1).reshape((1, 2, 3, 4))
X = tf.convert_to_tensor(_X)
Explanation: Q23. Given X below, reverse the last dimension.
End of explanation
_X = np.ones((1, 2, 3))
X = tf.convert_to_tensor(_X)
Explanation: Q24. Given X below, permute its dimensions such that the new tensor has shape (3, 1, 2).
End of explanation
_X = np.arange(1, 10).reshape((3, 3))
X = tf.convert_to_tensor(_X)
Explanation: Q25. Given X, below, get the first, and third rows.
End of explanation
_X = np.arange(1, 10).reshape((3, 3))
X = tf.convert_to_tensor(_X)
Explanation: Q26. Given X below, get the elements 5 and 7.
End of explanation
<END_TASK>