Code Monkey home page Code Monkey logo

torchtt's People

Contributors

ausstein avatar ion-g-ion avatar iongabrielion avatar xyntec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

torchtt's Issues

Scalar multiplication with complex numbers and torch.Tensor Scalars

Issue: Allowing Scalar Multiplications with Complex Numbers in Tensor Trains

Description:

  • When using torchTT, scalar multiplications with complex numbers are not supported. This seems to be an oversight as everything works perfectly when they are allowed.
  • Also multiplying with torch.Tensor scalars isinstance(other, tn.tensor) raises "TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union"

Steps to Reproduce:

  1. Attempt to multiply a tensor train with a complex scalar or torch.Tensor scalar.
  2. Observe the error.

Proposed Solution:
I have created a pull request to address this issue by:

  • Changing isinstance(other, tn.tensor) to isinstance(other, tn.Tensor) in def __mul__(self, other).
  • Adding support for complex scalars by adding or isinstance(other, complex).
  • Updating the descriptions and error messages accordingly.

Related Pull Request:

Broadcasting

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?

Numerical Representation Issue

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

Adding optimization option for Cross-Interpolation

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]

Can not import torchtt

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?

a problem with using torchTT.interpolate.dmrg_cross()

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.