def test_midpoint_name_shape(self): ch_in_num = 256 ch_out_num = 256 model_config = ConvModuleConfig() scope = 'unittest' stride = 2 kernel_size = 3 # test input shape input_shape = [None, 64, 64, ch_in_num] # expected output shape expected_output_height = input_shape[1] / stride expected_output_width = input_shape[2] / stride expected_output_shape = [ input_shape[0], expected_output_height, expected_output_width, ch_out_num ] inputs = create_test_input(batchsize=input_shape[0], heightsize=input_shape[1], widthsize=input_shape[2], channelnum=input_shape[3]) module_output, mid_points = get_module(ch_in=inputs, ch_out_num=ch_out_num, model_config=model_config, stride=stride, kernel_size=kernel_size, conv_type=TEST_MODULE_NAME, scope=scope) expected_midpoint = ModuleEndpointName( conv_type=TEST_MODULE_NAME, input_shape=input_shape, output_shape=expected_output_shape) print('------------------------------------------------') print('[tfTest] run test_midpoint_name_shape()') print('[tfTest] midpoint name and shape') self.assertItemsEqual(mid_points.keys(), expected_midpoint.name_list) for name, shape in six.iteritems(expected_midpoint.shape_dict): print('%s : shape = %s' % (name, shape)) self.assertListEqual(mid_points[name].get_shape().as_list(), shape)
def test_bicubic_resize_name_shape(self): scope = 'unittest' model_config = DeconvModuleConfig() TEST_MODULE_NAME = 'bicubic_resize' with tf.name_scope(name=scope): input_width = 2 input_height = 2 input_shape = [1, input_height, input_width, 1] unpool_rate = 2 expected_output_shape = [ input_shape[0], input_shape[1] * unpool_rate, input_shape[2] * unpool_rate, input_shape[3] ] inputs = create_test_input(batchsize=input_shape[0], heightsize=input_shape[1], widthsize=input_shape[2], channelnum=input_shape[3]) y_unpool2, midpoint = get_deconv_module( inputs=inputs, unpool_rate=unpool_rate, module_type=TEST_MODULE_NAME, model_config=model_config, scope=scope) expected_midpoint = ModuleEndpointName( conv_type=TEST_MODULE_NAME, input_shape=input_shape, output_shape=expected_output_shape) print('------------------------------------------------') print('[tfTest] run test_bicubic_resize_name_shape()') print('[tfTest] midpoint name and shape') print('[tfTest] unpool rate = %s' % unpool_rate) self.assertItemsEqual(midpoint.keys(), expected_midpoint.name_list) for name, shape in six.iteritems(expected_midpoint.shape_dict): print('%s : shape = %s' % (name, shape)) self.assertListEqual(midpoint[name].get_shape().as_list(), shape)