There's more...

We have to declare the data shape and know the outcome shape of the operations before we run data through the graph. This is not always the case. There may be a dimension or two that we do not know beforehand, or some that can vary. To accomplish this, we designate the dimension or dimensions that can vary (or is unknown) as value None. For example, to make the prior data placeholder have an unknown amount of columns, we would write the following line:

x_data = tf.placeholder(tf.float32, shape=(3,None))

This allows us to break matrix multiplication rules but we must still obey the fact that the multiplying constant must have the same number of rows. We can either generate this dynamically or reshape x_data as we feed data ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.