Numpy- Deep Learning, Training Examples -
silly question, going through third week of andrew ng's newest deep learning course, , getting stuck @ simple numpy function ( think? ).
the exercise find how many training examples, m , have.
any idea numpy function find out size of preloaded training example.
thanks!
shape_x = x.shape shape_y = y.shape m = ? print ('the shape of x is: ' + str(shape_x)) print ('the shape of y is: ' + str(shape_y)) print ('i have m = %d training examples!' % (m))
it depends on kind of storage-approach use.
most python-based tools use [n_samples, n_features]
approach first dimension sample-dimension, second dimension feature-dimension (like in scikit-learn , co.). alternatively expressed: samples rows , features columns.
so:
# feature 1 2 3 4 x = np.array([[1,2,3,4], # first sample [2,3,4,5], # second sample [3,4,5,6] ])
is training-set of 3 samples 4 features each.
the sizes m,n (again: interpretation might different others) can with:
m, n = x.shape
because numpy's first dimension rows, numpy's second dimension columns like in matrix-algebra.
for above example, target-array of shape (m) = n_samples
.
Comments
Post a Comment