Bug in int8 ndarray to tensor conversion or in my understanding?
I can obviously preallocate an appropriately sized CharTensor and then copy myself, but it seems like that shouldn’t be necessary.
mattmacy
Trying to work around it with a ByteTensor as dst and ndarray of uint8 as follows: <SCODE>def copy_tensor(dst, src):
    for z in range(Z_MAX):
        for y in range(Y_MAX):
            for x in range(X_MAX):
                val = src[z][y][x]
                dst[z][y][x] = val
<ECODE> The labels masks are 192x160x192, so it really would be nicer to keep them as single byte tensors.
mattmacy
this does work - albeit slowly. And it’s actually so slow as to be useless. <SCODE>def copy_tensor(dst, src):
    for z in range(Z_MAX):
        for y in range(Y_MAX):
            for x in range(X_MAX):
                val = src[z][y][x]
                if val != 0:
                    dst[z][y][x] = 1
<ECODE> It appears that the only ndarray to tensor conversion that actually works is floating point.
mattmacy
Hi,
albanD
Converting to np.uint8 and then calling from_numpy works. Thanks.
mattmacy
Thank you very much
xiao1228