Use PyTorch to adjust Tensor matrix values based on numbers I calculate from the Tensors?

29
August 24, 2019, at 10:40 PM

I have two tensors (matrices) that I've initialized:

sm=Var(torch.randn(20,1),requires_grad=True)
sm = torch.mm(sm,sm.t()) 
freq_m=Var(torch.randn(12,20),requires_grad=True)

I am creating two lists from the data inside these 2 matrices, and I am using spearmanr to get a correlation value between these 2 lists. How I am creating the lists is not important, but the goal is to adjust the values inside the matrices so that the calculated correlation value is as close to 1 as possible.

If I were to solve this problem manually, I would tweak values in the matrices by .01 (or some small number) each time and recalculate the lists and correlation score. If the new correlation value is higher than the previous one, I would save the 2 matrices and tweak a different value until I get the 2 matrices that give me the highest correlation score possible.

Is PyTorch capable of doing this automatically? I know PyTorch can adjust based on an equation but the way I want to adjust the matrix values is not against an equation, it's against a correlation value that I calculate. Any guidance with this is greatly appreciated!

READ ALSO
How can I skip a file when using os.listdir that has nothing written in it

How can I skip a file when using os.listdir that has nothing written in it

I am trying to go through all my files in a directory and make another text file that will eventually allow me to make plots out of my dataSome of the VariantLine# files do not contain any information in them because those variants were not found in any of my strains

47
What happened to pip in Windows, why is it no longer problematic to install packages? [on hold]

What happened to pip in Windows, why is it no longer problematic to install packages? [on hold]

Just now I saw myself in the situation where I had to install Paramiko on a new Windows machine

48
How to map elements to their index using streams?

How to map elements to their index using streams?

I get a stream of some custom objects and I would like to create a map Map<Integer, MyObject> with index of each object as keyTo give you a simple example:

46
Error creating bean with name &#39;getSessionFactory&#39; defined in com.shivam.spring.config.AppConfig:

Error creating bean with name 'getSessionFactory' defined in com.shivam.spring.config.AppConfig:

This error comes when i start my server Error creating bean with name 'getSessionFactory' defined in comshivam

42