In [1]:
from __future__ import print_function
import tensorflow as tf
import numpy as np
In [2]:
from datetime import date
date.today()
Out[2]:
In [3]:
author = "kyubyong. https://github.com/Kyubyong/tensorflow-exercises"
In [4]:
tf.__version__
Out[4]:
In [5]:
np.__version__
Out[5]:
In [6]:
sess = tf.InteractiveSession()
NOTE on notation
Q1. Let x and y be random 0-D tensors. Return x + y if x < y and x - y otherwise.
In [7]:
Q2. Let x and y be 0-D int32 tensors randomly selected from 0 to 5. Return x + y 2 if x < y, x - y elif x > y, 0 otherwise.
In [8]:
Q3. Let X be a tensor [[-1, -2, -3], [0, 1, 2]] and Y be a tensor of zeros with the same shape as X. Return a boolean tensor that yields True if X equals Y elementwise.
In [9]:
Q4. Given x and y below, return the truth value x AND/OR/XOR y element-wise.
In [10]:
x = tf.constant([True, False, False], tf.bool)
y = tf.constant([True, True, False], tf.bool)
Q5. Given x, return the truth value of NOT x element-wise.
In [11]:
x = tf.constant([True, False, False], tf.bool)
Q6. Let X be a tensor [[-1, -2, -3], [0, 1, 2]] and Y be a tensor of zeros with the same shape as x. Return a boolean tensor that yields True if X does not equal Y elementwise.
In [12]:
Q7. Let X be a tensor [[-1, -2, -3], [0, 1, 2]] and Y be a tensor of zeros with the same shape as X. Return a boolean tensor that yields True if X is greater than or equal to Y elementwise.
In [13]:
Q8. Let X be a tensor [[1, 2], [3, 4]], Y be a tensor [[5, 6], [7, 8]], and Z be a boolean tensor [[True, False], [False, True]]. Create a 2*2 tensor such that each element corresponds to X if Z is True, otherise Y.
In [14]:
In [ ]: