You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_layers_resampling.py 2.1 kB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import sys
  4. sys.path.append("/home/wurundi/workspace/tensorlayer2")
  5. import os
  6. import unittest
  7. os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
  8. import tensorlayer as tl
  9. from tensorlayer.layers import *
  10. from tests.utils import CustomTestCase
  11. class Layer_Pooling_Test(CustomTestCase):
  12. @classmethod
  13. def setUpClass(cls):
  14. ## 1D ========================================================================
  15. ## 2D ========================================================================
  16. x_2_input_shape = [None, 100, 100, 3]
  17. nin_2 = Input(x_2_input_shape)
  18. n6 = tl.layers.Conv2d(n_filter=32, filter_size=(3, 3), strides=(2, 2), name='test_conv2d')(nin_2)
  19. n7 = tl.layers.UpSampling2d(scale=(2, 2), name='test_UpSampling2d_1')(n6)
  20. n8 = tl.layers.UpSampling2d(scale=3, name='test_UpSampling2d_2')(n6)
  21. n9 = tl.layers.DownSampling2d(scale=(2, 2), name='test_DownSampling2d_1')(n6)
  22. n10 = tl.layers.DownSampling2d(scale=5, name='test_DownSampling2d_2')(n6)
  23. cls.n6_shape = n6.get_shape().as_list()
  24. cls.n7_shape = n7.get_shape().as_list()
  25. cls.n8_shape = n8.get_shape().as_list()
  26. cls.n9_shape = n9.get_shape().as_list()
  27. cls.n10_shape = n10.get_shape().as_list()
  28. @classmethod
  29. def tearDownClass(cls):
  30. pass
  31. # tf.reset_default_graph()
  32. def test_UpSampling2d(self):
  33. self.assertEqual(self.n7_shape[1:3], [100, 100])
  34. self.assertEqual(self.n8_shape[1:3], [150, 150])
  35. try:
  36. layer = tl.layers.UpSampling2d(scale=(2, 2, 2))
  37. except Exception as e:
  38. print(e)
  39. def test_DownSampling2d(self):
  40. self.assertEqual(self.n9_shape[1:3], [25, 25])
  41. self.assertEqual(self.n10_shape[1:3], [10, 10])
  42. try:
  43. layer = tl.layers.DownSampling2d(scale=(2, 2, 2))
  44. except Exception as e:
  45. print(e)
  46. if __name__ == '__main__':
  47. tl.logging.set_verbosity(tl.logging.DEBUG)
  48. unittest.main()

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.