ion-g-ion / torchtt Goto Github PK
View Code? Open in Web Editor NEWTensor-Train decomposition in pytorch
License: MIT License
Tensor-Train decomposition in pytorch
License: MIT License
Description:
Steps to Reproduce:
Proposed Solution:
I have created a pull request to address this issue by:
isinstance(other, tn.tensor)
to isinstance(other, tn.Tensor)
in def __mul__(self, other)
.or isinstance(other, complex)
.Related Pull Request:
Hey, I really like this project due to many functionalities that are not really available in other packages. However, the one thing that is currently missing (which most other packages have) is broadcasting, e.g. being able to multiply a (k, n, n, n) size tensor with an (n, n, n) tensor without having to use some kind of looping. This makes the handling of batch dimensions very difficult. Is there a particular reason that it is not yet implemented, or are you planning to add it to the library sometime in the future?
Dears,
I am having something that looks to me as numerical representation problems.
Here's and hopefully self explanatory example.
In essence I am trying to evaluate the same function in three different ways, and il looks like torchTT is provides a divergent value.
Please let me know if I am getting something wrong.
best,
NC
In the original paper by Sergei Goreinov, Ivan Oseledets, D. Savostyanov, E. Tyrtyshnikov, and Nickolai Zamarashkin "How to find a good submatrix" where maxvol routine was originally proposed, they stated that this method can help with finding not only submatrix with maximum volume in order to interpolate, but also with maximum element of the whole matrix(tensor), because of such submatrices often contain big elements(if not maximum). TT-Toolbox by Oseledets, on which you may base, have that optimization option implemented.
So i thought it may be useful to add same option here, in your lib. Especially when torchTT has much simplier installation, GPU and Torch compatibility and stuff, I'd prefer to use your lib instead of ttpy.
As i understood, all that is needed to implement such option is to when you do another maxvol procedure just update some Global-Maximum variable if needed with some bigger value from submatrix(if its bigger than Global_Maximum). Maybe this should be done not every iteration or maybe there're some other heuristics, better to check original papers. Anyways, it shouldn't be that hard especially when you already have cross-interpolation implemented.
Also, it seems that you've finally added DMRG to you lib, since I contacted you a year ago. Really can't wait to try it.
Please, contact me on email, because i no longer have @terraquantum.swiss mailbox.
Kuhmistrov Daniil, [email protected]
Hey @ion-g-ion, I have spotted a typo!
I was trying the torchtt package, but was not able to use it at all.
When run "import torchtt as tntt", it reports a TypeError : 'type' object is not subscriptable
on torchtt.py in TT(): cores: list[tn.tensor]
I tried it from downloading the package and run it on windows python 3.8.0, I also tried the directed linked colab notebook on torchTT repository, neither one is working
Is is a bug or am I missing something?
I tried to use interpolate.dmrg_cross() from a numpy array.
Generate a random array:
import numpy as np
import torch as tn
import torchtt as tntt
test = np.random.rand(10, 10, 10)
Define the function in this way:
def func(args):
return tn.tensor([tn.from_numpy(test)[*args[0]]], dtype=tn.complex128)
When I tried to use dmg_cross to interpolate this exemplary random tensor,
N = list(test.shape)
x = tntt.interpolate.dmrg_cross(func, N, eps=10**(-8))
I got the error message:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
^^^^^^
File "<input>", line 1, in <module>
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/boyuanshi/Desktop/second_project/equilibrium_v2/Screened_Interactions_Plot.py", line 61, in <module>
x = tntt.interpolate.dmrg_cross(func, N, eps=10**(-8))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/boyuanshi/.conda/envs/Desktop/lib/python3.11/site-packages/torchTT-2.0-py3.11-macosx-10.9-x86_64.egg/torchtt/interpolate.py", line 514, in dmrg_cross
supercore = tn.reshape(function(eval_index),[rank[k],N[k],N[k+1],rank[k+2]])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: shape '[1, 10, 10, 2]' is invalid for input of size 1
I am quite confused why it is the case?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.