Reputation: 43
I'm currently learning ML with julia and i've encoutered a problem when trying to do the dot product of 2 matrices, here is the code :
w, b = zeros(size(train_x, 1), 1), 0
println("Weights size : $(size(w'))")
println("Train X size : $(size(train_x))")
result = dot(w', train_x)
The shapes are :
* w shape : (1, 12288)
* train_x shape : (12288, 209)
This call give me an error which is :
DimensionMismatch("dot product arguments have lengths 12288 and 2568192")
Did i missed something ? This dot product is valid using numpy, so i'm a little bit confused.
Upvotes: 0
Views: 735
Reputation: 20950
The dot
function in Julia is only meant for dot products in the strict sense -- the inner product on a vector space, ie., between two vectors. It seems like you just want to multiply a vector with a matrix. In that case you can use
w = zeros(size(train_x, 1)) # no need for the extra dimension
result = w' * train_x
*
will do matrix-vector multiplication. In Julia, unlike in Numpy, but like in Matlab, .*
is instead used for elementwise multiplication.
Upvotes: 2