oseledets / oseledets/ttpy

`tt.optimize.tt_min.min_tens` does not work

Open
#91 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
264
Forks
73
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the reproduction in tt/optimize/example.py, then inspect tt/optimize/tt_min.py around the failing lookup and tt/core/vector.py around getitem. Trace the type and shape of x_full at the failing access. Done means the example completes without the IndexError and reports the minimum value and point.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.