| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import numpy as np | |
| 4 | 4 | import tensorflow as tf | |
| 5 | + from tensorflow.contrib.cudnn_rnn import CudnnGRU | ||
| 5 | 6 | ||
| 6 | 7 | from common import gpu_test | |
| 7 | 8 | ||
@@ -23,6 +24,23 @@ def test_conv2d(self): | |||
| 23 | 24 | with tf.Session() as sess: | |
| 24 | 25 | result = sess.run(op) | |
| 25 | 26 | self.assertEqual(4, len(result.shape)) | |
| 27 | + | ||
| 28 | + @gpu_test | ||
| 29 | + def test_cudnn_gru(self): | ||
| 30 | + input = tf.random_normal([1,2,2]) | ||
| 31 | + | ||
| 32 | + gru = CudnnGRU( | ||
| 33 | + num_layers=1, | ||
| 34 | + num_units=1, | ||
| 35 | + input_mode='skip_input', | ||
| 36 | + direction='unidirectional' | ||
| 37 | + ) | ||
| 38 | + | ||
| 39 | + op = gru(input) | ||
| 40 | + | ||
| 41 | + with tf.Session() as sess: | ||
| 42 | + # Will fail if Cudnn is not properly installed | ||
| 43 | + sess.run(op) | ||
| 26 | 44 | ||
| 27 | 45 | @gpu_test | |
| 28 | 46 | def test_gpu(self): | |
@@ -31,7 +49,7 @@ def test_gpu(self): | |||
| 31 | 49 | m2 = tf.constant([3.0, 4.0], shape=[2, 1], name='b') | |
| 32 | 50 | op = tf.matmul(m1, m2) | |
| 33 | 51 | ||
| 34 | - sess = tf.Session() | ||
| 35 | - result = sess.run(op) | ||
| 52 | + with tf.Session() as sess: | ||
| 53 | + result = sess.run(op) | ||
| 36 | 54 | ||
| 37 | - self.assertEqual(np.array(18, dtype=np.float32, ndmin=2), result) | ||
| 55 | + self.assertEqual(np.array(18, dtype=np.float32, ndmin=2), result) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments