Why is it that only one value is taken in the cells shown below for weights instantiation?

In the lab “C2_W1_Lab01_Neurons_and_Layers”,


Why did we take only one example?
I tried to remove the indexing zero ([0]) and got the following:

In the above snap, the weight has only one element even though I (intentionally) modified it’s above cell to have two weights(which is incorrect for a single feature NN though). Not able to grasp what happened. Someone please enlighten me on this.

Hello @Devarapalli_Vamsi,

You actually did not modify it into two weights.

image

-1 makes the zeroth axis to have free length, and the 1 makes the first axis to have exactly length one. This essentially makes the training dataset into one that has any number of samples and one feature per sample. If you are not sure what I am talking here, you need to study and experiment what reshape does.

Therefore, by taking away [0], you did NOT modify anything about the weights. You only modified something about the dataset. This → image actually proves that you still only had one weight.

Try to rethink this whole thing with what I just told you here in mind.

Cheers,
Raymond

Hi @rmwkwok , I had gone through the lab again and understood what’s happening under the hood.


1.The number of (weight, bias) pairs in a layer correspond to number of units it
contains.
2.But, these weights and biases won’t be instantiated (of course with random numbers) unless the layer gets to work with at least one sample from the training samples.
3. Now, due to cell 6, weights got instantiated. of course, those number of weights equal to the number of units that are present in the layer gets instantiated irrespective of the number of samples the layer got exposed to (but minimum it should get exposed to is one).
4.Now, each sample in the training data gets multiplied to weight in each neuron and bias be added which gives me 6 values in my tensor.(2 training samples*3 units in my layer).

Please correct me if I am wrong anywhere.
Thanks

1 Like

Hello @Devarapalli_Vamsi,

They are perfect! :raised_hands:

Cheers,
Raymond

1 Like

Hey @rmwkwok , just one more validation required from you.
“The number of weights in ‘each unit’ of the layer correspond to the number of features.”
Please validate this with a simple like if it’s correct.
Thanks for the support :heart:

1 Like

Yes, correct!

Cheers!

1 Like