Linear Algebra

Hi! I’m not sure what :eqref:eq_matrix_def is supposed to refer to in section 2.3.3

Hi @Briana_Brady, sorry for not rendered labels, we will fix it. It should point to the equation 2.3.2.

Thank you for your quick response!

Here in the Linear-Algebra-Exercises section’s 6th question, it is asked to
“Run A / A.sum(axis=1) and see what happens.” and find out why but I’m getting an error.

At first it said
AttributeError: ‘tensorflow.python.framework.ops.EagerTensor’ object has no attribute 'sum’

So I used reduce_sum and again it raised an error.

InvalidArgumentError: Incompatible shapes: [5,4] vs. [5] [Op:RealDiv]

Can you help me with this?

Thanking you in advance.

Hi @Sumanth, good question! The numerator and denominator need to have the same type. (Think of how the machine knows which axis to apply division. :wink: ) It is pretty common to see the shape mismatch in deep learning. Just check the document and find more details, for e.g. TF division here.

Hi, may I join the discussion :smiley: , since I also got the same problem trying to run that line, even with tf.math.divide. What I think the question is asking is: divide the matrix to an array, so for each row of the matrix, it is divided by the sum of that row, so I would suggest mine: A / tf.reshape(tf.reduce_sum(A,axis=1),(-1,1))

Hey @randomonlinedude, thanks for the great suggestion! Would you like to post a PR on our git and become a contributor?

1 Like

Thanks. Now it’s fixed. See comments in

@goldpiggy Hi, sorry for the late reply, I didnt see the notice :smiley: yes, if I can do something for this book, I would love to. Thank you for the work of your team and you :blush: