Skip to content

Commit

Permalink
Embedding layer - cast float to int implicitly (keras-team#3342)
Browse files Browse the repository at this point in the history
* Embedding layer - cast float to int implicitly

* Cast only if not int
  • Loading branch information
farizrahman4u authored and fchollet committed Jul 29, 2016
1 parent b6d23b2 commit cb4de1f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions keras/layers/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def get_output_shape_for(self, input_shape):
return (input_shape[0], input_length, self.output_dim)

def call(self, x, mask=None):
if K.dtype(x) != 'int32':
x = K.cast(x, 'int32')
if 0. < self.dropout < 1.:
retain_p = 1. - self.dropout
B = K.random_binomial((self.input_dim,), p=retain_p) * (1. / retain_p)
Expand Down

0 comments on commit cb4de1f

Please sign in to comment.