Skip to content

tt.optimize.tt_min.min_tens does not work #91

@tzoiker

Description

@tzoiker

tt.optimize.tt_min.min_tens does not work at least for ttpy==1.2.1

How to reproduce: example

import tt
from tt.optimize import tt_min
tens = tt.rand([3, 4, 5, 4, 3], 5, 3)
min_element = min(tens.full().flatten())
print("Minimize random 5-dimensional TT tensor with ranks equal to 3. " +
      "The minimal element is %f" % min_element)
val, point = tt_min.min_tens(tens, rmax=10, nswp=30)

Gives the following error:

Minimize random 5-dimensional TT tensor with ranks equal to 3. The minimal element is -15.459226
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/tmp/ipykernel_23243/3135023836.py in <module>
      5 print("Minimize random 5-dimensional TT tensor with ranks equal to 3. " +
      6       "The minimal element is %f" % min_element)
----> 7 val, point = tt_min.min_tens(tens, rmax=10, nswp=30)

~/storage/miniconda2/envs/cqfs/lib/python3.7/site-packages/tt/optimize/tt_min.py in min_tens(tens, rmax, nswp, verb, smooth_fun)
    214             lm = min_cur
    215             x_full = J[ind_cur, :]
--> 216             val = tens[x_full]
    217             if verb:
    218                 print('New record:', val, 'Point:', x_full, 'elements seen:', elements_seen)

~/storage/miniconda2/envs/cqfs/lib/python3.7/site-packages/tt/core/vector.py in __getitem__(self, index)
    173                 (self.r[i], self.n[i], self.r[i + 1]), order='F')
    174             cur_core = cur_core[
--> 175                 :, index[i], :].reshape(
    176                 (self.r[i], -1), order='F')
    177             if running_fact is None:

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions