Skip to content
Advertisement

Select a column without “losing” a dimension

Suppose I execute the following code

JavaScript

The shape of X[:,1] would be [100,]. That is, X[:,1].shape would yield [100,]. If I want to select the second column of X and want the resulting array to have shape [100,1], what should I do? I looked at tf.slice but I’m not sure if it’ helpful.

Advertisement

Answer

Maybe just use tf.newaxis for your use case:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement