Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty in instantiating TensorTrain from tt_cores #113

Closed
AustenLamacraft opened this issue Feb 28, 2018 · 8 comments
Closed

Difficulty in instantiating TensorTrain from tt_cores #113

AustenLamacraft opened this issue Feb 28, 2018 · 8 comments
Assignees

Comments

@AustenLamacraft
Copy link

I have the following problem that I don't know how to get around... would really appreciate any advice.

I want to form model inputs into TT cores and use them to instantiate a TensorTrain (I can't do to_tt_tensor because the number of inputs is too large -- the full tensor would be huge)

However, since TensorTrain does tt_cores = list(tt_cores), I get the (Tensorflow) error

TypeError: `Tensor` objects are not iterable when eager execution is not enabled. To iterate over this tensor use `tf.map_fn`.

(tf.map_fn doesn't solve the problem, of course). Eager execution doesn't work at present:

import tensorflow as tf
import tensorflow.contrib.eager as tfe
import t3f

tfe.enable_eager_execution()

shape = (3, 4, 4, 5, 7, 5)
initialization = t3f.random_tensor(shape, tt_rank=5)
estimated = t3f.get_variable('estimated', initializer=initialization)

yielding

ValueError: ValueError: Variable estimated does not exist, or was not created with t3f.get_tt_variable(). Did you mean to set reuse=None in VarScope?
@Bihaqo
Copy link
Owner

Bihaqo commented Feb 28, 2018 via email

@AustenLamacraft
Copy link
Author

Thanks, that works. I was using a tfe.Iterator to get data, which produces Tensors, but I guess there's no need.

On the other hand, it would be great if t3f would work in eager mode. Do you have any idea how hard it is? I'd be happy to give it a try...

@Bihaqo
Copy link
Owner

Bihaqo commented Mar 1, 2018

Hm, I'll take a look, thanks for the request.

@KhrulkovV KhrulkovV self-assigned this Mar 2, 2018
@AustenLamacraft
Copy link
Author

It seems that a hacky solution is to change variables.py at line 58 from if reuse to if reuse is True as here. I suspect this will mess up variable reuse, though.

@KhrulkovV
Copy link
Collaborator

It seems that the problem is that if eager mode is enabled then reuse is always true, so the code tries to find the TensorTrainVariables collection and crashes. I tried to fix it as in the tensorflow code, e.g. if reuse and not context.in_eager_mode() and it seems to be working, will upload soon.

@AustenLamacraft
Copy link
Author

tf.get_variable_scope().reuse = <_ReuseMode.AUTO_REUSE: 1> in eager mode, which is why if reuse was causing the original error, and why if reuse is True fixes it.

@Bihaqo
Copy link
Owner

Bihaqo commented Mar 5, 2018

#114

@Bihaqo Bihaqo closed this as completed Mar 9, 2018
@cw-plus
Copy link

cw-plus commented May 30, 2018

Hi, for I can only use cuda 8.0, and install tensorflow below 1.5.0. How I can solve this problem? please help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants