Skip to content
Advertisement

In numpy, what does selection by [:,None] do?

I’m taking the Udacity course on deep learning and I came across the following code:

JavaScript

What does labels[:,None] actually do here?

Advertisement

Answer

http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

numpy.newaxis

The newaxis object can be used in all slicing operations to create an axis of length one. :const: newaxis is an alias for ‘None’, and ‘None’ can be used in place of this with the same result.

http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.expand_dims.html

Demonstrating with part of your code

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