(self, X)
| 1035 | X=hu.arrays(dims=[2, 5]), |
| 1036 | ) |
| 1037 | def testBatchNormalization(self, X): |
| 1038 | input_record = self.new_record(schema.Scalar((np.float32, (5,)))) |
| 1039 | schema.FeedRecord(input_record, [X]) |
| 1040 | bn_output = self.model.BatchNormalization(input_record) |
| 1041 | self.assertEqual(schema.Scalar((np.float32, (5,))), bn_output) |
| 1042 | self.model.output_schema = schema.Struct() |
| 1043 | |
| 1044 | train_init_net, train_net = self.get_training_nets() |
| 1045 | |
| 1046 | init_ops = self.assertNetContainOps( |
| 1047 | train_init_net, |
| 1048 | [ |
| 1049 | OpSpec("ConstantFill", None, None), |
| 1050 | OpSpec("ConstantFill", None, None), |
| 1051 | OpSpec("ConstantFill", None, None), |
| 1052 | OpSpec("ConstantFill", None, None), |
| 1053 | ] |
| 1054 | ) |
| 1055 | |
| 1056 | input_blob = input_record.field_blobs()[0] |
| 1057 | output_blob = bn_output.field_blobs()[0] |
| 1058 | |
| 1059 | expand_dims_spec = OpSpec( |
| 1060 | "ExpandDims", |
| 1061 | [input_blob], |
| 1062 | None, |
| 1063 | ) |
| 1064 | |
| 1065 | train_bn_spec = OpSpec( |
| 1066 | "SpatialBN", |
| 1067 | [None, init_ops[0].output[0], init_ops[1].output[0], |
| 1068 | init_ops[2].output[0], init_ops[3].output[0]], |
| 1069 | [output_blob, init_ops[2].output[0], init_ops[3].output[0], None, None], |
| 1070 | {'is_test': 0, 'order': 'NCHW', 'momentum': 0.9}, |
| 1071 | ) |
| 1072 | |
| 1073 | test_bn_spec = OpSpec( |
| 1074 | "SpatialBN", |
| 1075 | [None, init_ops[0].output[0], init_ops[1].output[0], |
| 1076 | init_ops[2].output[0], init_ops[3].output[0]], |
| 1077 | [output_blob], |
| 1078 | {'is_test': 1, 'order': 'NCHW', 'momentum': 0.9}, |
| 1079 | ) |
| 1080 | |
| 1081 | squeeze_spec = OpSpec( |
| 1082 | "Squeeze", |
| 1083 | [output_blob], |
| 1084 | [output_blob], |
| 1085 | ) |
| 1086 | |
| 1087 | self.assertNetContainOps( |
| 1088 | train_net, |
| 1089 | [expand_dims_spec, train_bn_spec, squeeze_spec] |
| 1090 | ) |
| 1091 | |
| 1092 | eval_net = self.get_eval_net() |
| 1093 | |
| 1094 | self.assertNetContainOps( |
nothing calls this directly
no test coverage detected