tt.reshape not working properly
y=tt.rand(2,11,3); yr=tt.reshape(y,[2,2**10]);
Error for ys=yr.round(1e-6) Error for print(yr[1,1])
It works fine for me.
In [2]: y = tt.rand(2, 11, 3)
...: yr = tt.reshape(y, [2, 2 ** 10])
...: ys = yr.round(1e-6)
...: print(yr[1, 1])
-6.180037546754562
Could you provide more details (at least traceback)?
Thanks for your message, Daniel. Here's the error in colab:
!pip install ttpy y = tt.rand(2, 11, 3) yr = tt.reshape(y, [2, 2 ** 10])
ys = yr.round(1e-6)
ValueError Traceback (most recent call last)
ValueError: failed to initialize intent(inout) array -- expected elsize=4 but got 8 -- input 'd' not compatible to 'i'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tt/core/vector.py https://localhost:8080/# in round(self, eps, rmax) 410 c.core = _tt_f90.tt_f90.zcore.copy() 411 else: --> 412 _tt_f90.tt_f90.dtt_compr2(c.n, c.r, c.ps, self.core, eps, rmax) 413 c.core = _tt_f90.tt_f90.core.copy() 414 _tt_f90.tt_f90.tt_dealloc()
ValueError: failed in converting 3rd argument `ps' of tt_f90.tt_f90.dtt_compr2 to C/Fortran array
print(yr[1, 1])
TypeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tt/core/vector.py https://localhost:8080/# in getitem(self, index) 169 for i in xrange(self.d): 170 # r0, n, r1 = cores[i].shape --> 171 cur_core = self.core[self.ps[i] - 1:self.ps[i + 1]
- 1] 172 cur_core = cur_core.reshape( 173 (self.r[i], self.n[i], self.r[i + 1]), order='F')
TypeError: slice indices must be integers or None or have an index method
On Wed, Jul 21, 2021 at 6:19 AM Daniel Bershatsky @.***> wrote:
It works fine for me.
In [2]: y = tt.rand(2, 11, 3) ...: yr = tt.reshape(y, [2, 2 ** 10]) ...: ys = yr.round(1e-6) ...: print(yr[1, 1])-6.180037546754562
Could you provide more details (at least traceback)?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/oseledets/ttpy/issues/84#issuecomment-884073613, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2LEC2NUMVJPER6EWVKH3TY2NJRANCNFSM5AW63IPA .
--
Victor S. Batista
John Randolph Huffman Professor of Chemistry
Yale University, Department of Chemistry
Yale Quantum Institute & Yale Energy Sciences Institute
ACS Associate Editor, JCTC
E-mail: @.***
http://ursula.chem.yale.edu/~batista/
Phone: (203)432-6672
Fax: (203)432-6144
Office: 115 SCL
The issue has been already fixed. However, the fix is not published to PyPI. I guess that the preferred installation way is building from source tree. Fortunately, it could be done easily in Colab as follows.
!pip install git+https://github.com/oseledets/ttpy.git@refs/pull/87/head
As soon as #87 is merged you can drop @... suffix and run.
!pip install git+https://github.com/oseledets/ttpy.git
@oseledets Can we bump package version and upload it to PyPI?
Thanks a lot, Daniel! Works like a charm. Victor.
On Wed, Jul 21, 2021 at 6:17 PM Daniel Bershatsky @.***> wrote:
The issue has been already fixed. However, the fix is not published to PyPI. I guess that the preferred installation way is building from source tree. Fortunately, it could be done easily in Colab as follows.
!pip install @.***/pull/87/head
As soon as #87 https://github.com/oseledets/ttpy/pull/87 is merged you can drop @... suffix and run.
!pip install git+https://github.com/oseledets/ttpy.git
@oseledets https://github.com/oseledets Can we bump package version and upload it to PyPI?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/oseledets/ttpy/issues/84#issuecomment-884535124, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2LEGA7N4H327SS4PAG6LTY5BPXANCNFSM5AW63IPA .
--
Victor S. Batista
John Randolph Huffman Professor of Chemistry
Yale University, Department of Chemistry
Yale Quantum Institute & Yale Energy Sciences Institute
ACS Associate Editor, JCTC
E-mail: @.***
http://ursula.chem.yale.edu/~batista/
Phone: (203)432-6672
Fax: (203)432-6144
Office: 115 SCL
Dear Daniel: Sorry, tt.reshape is still not working well. Here's a test code showing that slice1 is correct but slice2 is not. Victor.
!pip install @./pull/87/head import tt import numpy as np import matplotlib.pyplot as plt N=2;d=5;ns=2d; x=2(np.linspace(0,ns-1,ns)*2/ns-1);xx=np.reshape(x, [2]*d)
xx = tt.tensor(xx);ttone=tt.ones(2, d)
def gen_1d(mat,e,i,d): w = mat for j in range(i): w = tt.kron(w,e) for j in range(d-i-1): w = tt.kron(e,w) return w
ttx = [gen_1d(xx,ttone,i,N) for i in range(N)]
def FUNCS(r): nevals, dim = r.shape out = np.zeros((nevals,)) for ii in range(nevals): out[ii]=np.exp(-np.sum(r[ii,:]**2)) return out
y=tt.multifuncrs(ttx, FUNCS, eps= 1e-14,verb=0)
y1=np.reshape(y.full(),[ns,ns]) slice1=y1[:,16]
y2=tt.reshape(y,[ns,ns]) slice2=y2[:,16].full()
plt.plot(x,slice1) plt.plot(x,slice2) plt.plot(x,np.exp(-x**2),'o')
On Wed, Jul 21, 2021 at 6:17 PM Daniel Bershatsky @.***> wrote:
The issue has been already fixed. However, the fix is not published to PyPI. I guess that the preferred installation way is building from source tree. Fortunately, it could be done easily in Colab as follows.
!pip install @.***/pull/87/head
As soon as #87 https://github.com/oseledets/ttpy/pull/87 is merged you can drop @... suffix and run.
!pip install git+https://github.com/oseledets/ttpy.git
@oseledets https://github.com/oseledets Can we bump package version and upload it to PyPI?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/oseledets/ttpy/issues/84#issuecomment-884535124, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2LEGA7N4H327SS4PAG6LTY5BPXANCNFSM5AW63IPA .
--
Victor S. Batista
John Randolph Huffman Professor of Chemistry
Yale University, Department of Chemistry
Yale Quantum Institute & Yale Energy Sciences Institute
ACS Associate Editor, JCTC
E-mail: @.***
http://ursula.chem.yale.edu/~batista/
Phone: (203)432-6672
Fax: (203)432-6144
Office: 115 SCL
Confirmed. It seems like TT cores are merged incorrectly.