TensowFlow Flashcards
Writing and running programs in TensorFlow has the following steps:
Create Tensors (variables) that are not yet executed/evaluated.
Write operations between those Tensors.
Initialize your Tensors.
Create a Session.
Run the Session. This will run the operations you’d written above
What is a placeholder?
A placeholder is an object whose value you can specify only later.
How do you put values in a placholder?
You use the function feed_dict, feed_dict = {x: 3}
How do you do a matrix multiplication in tensforflow?
tf.matmul(…, …) to do a matrix multiplication
Addition in tensorflow?
tf.add(…, …) to do an addition
random initialization in python
np.random.randn(…) to initialize randomly
how would you define a constant X that has shape (3,1)?
X = tf.constant(np.random.randn(3,1), name = “X”)
How would you declare a placeholder?
tf.placeholder( dtype, shape=None, name=None ) E.g. x = tf.placeholder(tf.float32, shape=(1024, 1024))
How would you initialize parameters in tensorflow?
tf.get_variable( name, shape=None, dtype=None, initializer=None, regularizer=None, trainable=True, collections=None, caching_device=None, partitioner=None, validate_shape=True, use_resource=None, custom_getter=None, constraint=None )
How to do a 2d convolution in TF?
tf.nn.conv2d(X,W1, strides = [1,s,s,1], padding = ‘SAME’)
how to maxpool in TF?
tf.nn.max_pool(A, ksize = [1,f,f,1], strides = [1,s,s,1], padding = ‘SAME’):
how to ReLU in TF?
tf.nn.relu(Z1
How to flatten a layer in TF?
tf.contrib.layers.flatten(P)
How to do a fully connected layer in TF?
tf.contrib.layers.fully_connected(F, num_outputs)
How do you softmax with several labels in TF?
tf.nn.softmax_cross_entropy_with_logits(logits = Z3, labels = Y)