(self)
| 839 | ) |
| 840 | |
| 841 | def testSamplingTrain(self): |
| 842 | output_dims = 1000 |
| 843 | |
| 844 | indices = self.new_record(schema.Scalar((np.int32, (10,)))) |
| 845 | sampling_prob = self.new_record(schema.Scalar((np.float32, (10, )))) |
| 846 | |
| 847 | sampled_fc = self.model.SamplingTrain( |
| 848 | schema.Struct( |
| 849 | ('input', self.model.input_feature_schema.float_features), |
| 850 | ('indices', indices), |
| 851 | ('sampling_prob', sampling_prob), |
| 852 | ), |
| 853 | "FC", |
| 854 | output_dims, |
| 855 | ) |
| 856 | self.model.output_schema = sampled_fc |
| 857 | |
| 858 | # Check that we don't add prediction layer into the model |
| 859 | self.assertEqual(1, len(self.model.layers)) |
| 860 | |
| 861 | self.assertEqual( |
| 862 | schema.Scalar((np.float32, (output_dims, ))), |
| 863 | sampled_fc |
| 864 | ) |
| 865 | |
| 866 | train_init_net, train_net = self.get_training_nets() |
| 867 | |
| 868 | init_ops = self.assertNetContainOps( |
| 869 | train_init_net, |
| 870 | [ |
| 871 | OpSpec("UniformFill", None, None), |
| 872 | OpSpec("UniformFill", None, None), |
| 873 | ] |
| 874 | ) |
| 875 | |
| 876 | sampled_fc_layer = self.model.layers[0] |
| 877 | |
| 878 | gather_w_spec = OpSpec( |
| 879 | "Gather", |
| 880 | [ |
| 881 | init_ops[0].output[0], |
| 882 | indices(), |
| 883 | ], |
| 884 | [ |
| 885 | sampled_fc_layer._prediction_layer.train_param_blobs[0] |
| 886 | ] |
| 887 | ) |
| 888 | gather_b_spec = OpSpec( |
| 889 | "Gather", |
| 890 | [ |
| 891 | init_ops[1].output[0], |
| 892 | indices(), |
| 893 | ], |
| 894 | [ |
| 895 | sampled_fc_layer._prediction_layer.train_param_blobs[1] |
| 896 | ] |
| 897 | ) |
| 898 | train_fc_spec = OpSpec( |
nothing calls this directly
no test coverage detected