Skip to content
Permalink
Browse files

fix(encoder): fix eager execution

  • Loading branch information...
hanxiao committed Aug 26, 2019
1 parent 3600c29 commit ff7926d886f3e7a0e93b18fee9b3810b048d1443
Showing with 5 additions and 43 deletions.
  1. +5 −2 gnes/encoder/numeric/pooling.py
  2. +0 −41 tests/test_elmo_encoder.py
@@ -28,7 +28,10 @@ def post_init(self):
self.torch = torch
elif self.backend == 'tensorflow':
import tensorflow as tf
tf.enable_eager_execution()
try:
tf.enable_eager_execution()
except ValueError:
pass
self.tf = tf

def mul_mask(self, x, m):
@@ -53,7 +56,7 @@ def masked_reduce_mean(self, x, m, jitter: float = 1e-10):
self.torch.sum(m.unsqueeze(2), dim=1) + jitter)
elif self.backend == 'tensorflow':
return self.tf.reduce_sum(self.mul_mask(x, m), axis=1) / (
self.tf.reduce_sum(m, axis=1, keepdims=True) + jitter)
self.tf.reduce_sum(m, axis=1, keepdims=True) + jitter)
elif self.backend == 'numpy':
return np.sum(self.mul_mask(x, m), axis=1) / (np.sum(m, axis=1, keepdims=True) + jitter)

This file was deleted.

0 comments on commit ff7926d

Please sign in to comment.
You can’t perform that action at this time.