DLS Course 2 - Wk 3 - Ex 3 One_hot_matrix - Reshape Errors

The documentation for tf.reshape(tensor, shape, name=None) states that the shape argument must be:

A Tensor. Must be one of the following types: int32, int64. Defines the shape of the output tensor.

Every example on the documentation page passes the shape using square brackets:

tf.reshape(t, [ 2, -1, 3])

I suspect that within function parameters, anything inside [...] is assumed to be a numpy array, which qualifies as a tensor.

depth or (depth) are probably parsed as numeric types and definitely don’t work. I assume that (depth, ) or (depth, 1) are implicitly cast to tensor types by the function parser.

2 Likes