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

Implicitly cast input to tensor (e.g., tf.convert_to_tensor) in layer functions? #6979

Closed
dustinvtran opened this Issue Jun 14, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@dustinvtran

dustinvtran commented Jun 14, 2017

In version <=2.0.4, Keras layers implicitly cast an input to a TensorFlow tensor as it goes through computation (it does this because the layer calls TensorFlow primitives which do the implicit casting).

A key application is the Edward probabilistic programming language. Consider a generative decoder:

from edward.models import Normal, Bernoulli
from keras.layers import Dense

batch_size = 128
latent_dim = 100

z = Normal(0.0, 1.0, sample_shape=[batch_size, latent_dim])
h = Dense(256)(z)
x = Bernoulli(logits=h)

This works in Keras <=2.0.4 because the layer calls tf.convert_to_tensor() on the input before doing computation. However, the line h = Dense(256)(z) fails in 2.0.5 due to #6593: is_keras_tensor(z) raises a value error.

Is the restriction to symbolic tensors (and not including implicitly castable tensors) on purpose?

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Oct 1, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

stale bot commented Oct 1, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the stale label Oct 1, 2017

@stale stale bot closed this Oct 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment