Andrew discusses the differences but why use numpy at all since TensorFlow is apparently a superset?
Hi @toontalk, excellent question! TensorFlow is indeed pretty powerful framework, but has some limitations, for example if we create a tensor and decide to update individual elements
w = tf.Variable([[1., 2.], [3., 4.]])
w
<tf.Variable ‘Variable:0’ shape=(2, 2) dtype=float32, numpy=
array([[1., 2.],
[3., 4.]], dtype=float32)>
we can’t simply assign a new value like this:
w[0,0] = 2.
Traceback (most recent call last):
File “”, line 1, in
TypeError: ‘ResourceVariable’ object does not support item assignment
in order to do this task we have to do something like
w[0,0].assign(2.)
<tf.Variable ‘UnreadVariable’ shape=(2, 2) dtype=float32, numpy=
array([[2., 2.],
[3., 4.]], dtype=float32)>
In numpy it is easier to do such kinds of operations, and it is very useful library for ML practitioner.
Thanks, makes sense.