google / prettytensor

Pretty Tensor: Fluent Networks in TensorFlow
1.24k stars 151 forks source link

VarStoreMethod creates tensors as opposed to variables #28

Open neocxi opened 8 years ago

neocxi commented 8 years ago

When passed in an initializer that's not callable, a tensor is created as opposed a variable: https://github.com/google/prettytensor/blob/564941199cdef8a9c8a570de51e04ce860714ed1/prettytensor/pretty_tensor_class.py#L1699

eiderman commented 8 years ago

This is intentional and the documentation will be improved with examples. For advanced networks, it can sometimes be advantageous to supply a variable to be shared, or a Tensor that is derived from another variable under the users control. The only way to do this is to allow a user to wire in an arbitrary Tensor.

If you want to take a snapshot of a Tensor at initialization, then you need to wrap it as an initializer function. This has the advantage of making it much easier to define arbitrary reusable Variables. It is also very flexible since it is called at graph construction time, you can even use it initialize to numpy constants (note: this does create huge constants in your graph).

On Mon, Jul 25, 2016 at 11:46 PM, (Peter) Xi Chen notifications@github.com wrote:

When passed in an initializer that's not callable, a tensor is created as opposed a variable: https://github.com/google/prettytensor/blob/564941199cdef8a9c8a570de51e04ce860714ed1/prettytensor/pretty_tensor_class.py#L1699

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/prettytensor/issues/28, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnmwBG__aK0w_z7dWo9T3LrFzwWWVRbks5qZa0ogaJpZM4JU1Zh .