Thanks!

I am trying to use very small matrices. Is there any way to calculate the 
partial derivatives of "loss2" below?

import numpy as np
from sympy import *

n, d, n2, d2 = 5, 7, 4, 3

x = np.random.randn(n, d)
y = np.random.randn(n, d2)

w1 = MatrixSymbol("l", 7, 4)
w1 = Matrix(w1)

w2 = MatrixSymbol("p", 4, 3)
w2 = Matrix(w2)

h2 = x * w1
predicted = h2 * w2

loss2 = Matrix(np.square(predicted - y))



On Saturday, May 30, 2020 at 10:27:14 PM UTC+2, David Bailey wrote:
>
> On 30/05/2020 15:02, Giuseppe G. A. Celano wrote:
>
> Enter code here...
>
> I am trying to perform a dot multiplication between a numpy array 
> (64,1000) and a sympy matrix (1000, 100) containing only variables, but the 
> computation never ends. How to do that?
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/402c5bd3-b503-4a45-9ea4-6754a4e49a23%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sympy/402c5bd3-b503-4a45-9ea4-6754a4e49a23%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> That calculation is going to create matrix with 6,400 elements, each of 
> which will be a summation of 1000 terms (at least before any possible 
> simplification, and assuming you mean variables without a numeric value). 
> Bearing in mind that symbolic expressions take quite a lot of memory, that 
> lot is going to take up a fair bit of memory but I'd guess it would be OK 
> in 64 bits (you don't say if your Python installation is 64bits as opposed 
> to 32 bits).
>
> However, calculating something that size is certainly going to be 
> challenging, and may need to run over night. In addition there is the 
> problem that the program may be choking trying to print the result.
>
> My advice would be to start with a much scaled down example, and then 
> gradually scale it up to see what breaks.
>
> If you want to do something immediately to use the matrix without printing 
> the 64 x 100 matrix of algebraic expressions (!!) that might be best.
>
> Good luck!
>
> David
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/e08c1707-afc7-4071-9330-e2e6dd855811%40googlegroups.com.

Reply via email to