Closed liangyuanhui closed 3 years ago
Just pass a tl.tensor
directly to tucker. We already wrap them in variables.
In other words, you can change your code to:
tl.set_backend('tensorflow')
tensor = tl.tensor(tl.randn(shape))
tucker_tensor = tucker(tensor, rank=[2,2,2])
Closing, but feel free to reopen if this doesn't solve your issue!
Hi, when i used the code below,encountered this problem“AttributeError: 'Tensor' object has no attribute 'numpy'”,can you help me?
My environment is tensorflow=1.15,tensorly=0.6, google colab,
`import tensorflow as tf tf.enable_eager_execution()
import tensorly as tl tl.set_backend('tensorflow') import numpy as np
tfe = tf.contrib.eager
from tensorly.tucker_tensor import tucker_to_tensor
from tensorly import check_random_state from tensorly.metrics import RMSE
import numpy as np
import sys from tensorflow.python.framework import ops
import os random_state = 1234 from tensorly.decomposition import tucker rng = check_random_state(random_state) shape=[5,12,120] ten = tfe.Variable(tl.tensor(rng.random_sample(shape))) ten1=tfe.Variable(tl.tensor(np.round(np.random.normal(0, 0.1, size=(5, 12, 120)),2)))
c,f = tucker(tf.convert_to_tensor(ten),rank=[2,2,2])`
I want use trunk when variable tf.variable ,tl.tucker_to_tensor in tf.loop ,Can you provide examples like tensorflow_tucker.ipynb?
Thank you!