コード例 #1
0
 def _deconv_matching_assert(self, model, output_layer, test_input):
     out = model(test_input)
     attrib = Deconvolution(model)
     neuron_attrib = NeuronDeconvolution(model, output_layer)
     for i in range(out.shape[1]):
         deconv_vals = attrib.attribute(test_input, target=i)
         neuron_deconv_vals = neuron_attrib.attribute(test_input, (i, ))
         assertTensorAlmostEqual(self,
                                 deconv_vals,
                                 neuron_deconv_vals,
                                 delta=0.01)
コード例 #2
0
ファイル: test_deconvolution.py プロジェクト: wmmxk/captum
 def _deconv_matching_assert(
     self,
     model: Module,
     output_layer: Module,
     test_input: TensorOrTupleOfTensorsGeneric,
 ) -> None:
     out = model(test_input)
     attrib = Deconvolution(model)
     self.assertFalse(attrib.multiplies_by_inputs)
     neuron_attrib = NeuronDeconvolution(model, output_layer)
     for i in range(out.shape[1]):
         deconv_vals = attrib.attribute(test_input, target=i)
         neuron_deconv_vals = neuron_attrib.attribute(test_input, (i,))
         assertTensorAlmostEqual(self, deconv_vals, neuron_deconv_vals, delta=0.01)
コード例 #3
0
ファイル: test_deconvolution.py プロジェクト: wmmxk/captum
 def _neuron_deconv_test_assert(
     self,
     model: Module,
     layer: Module,
     neuron_index: Union[int, Tuple[int, ...]],
     test_input: TensorOrTupleOfTensorsGeneric,
     expected: Tuple[List[List[float]], ...],
     additional_input: Any = None,
 ) -> None:
     deconv = NeuronDeconvolution(model, layer)
     attributions = deconv.attribute(
         test_input,
         neuron_index=neuron_index,
         additional_forward_args=additional_input,
     )
     for i in range(len(test_input)):
         assertTensorAlmostEqual(self, attributions[i], expected[i], delta=0.01)
コード例 #4
0
 def _neuron_deconv_test_assert(self,
                                model,
                                layer,
                                neuron_index,
                                test_input,
                                expected,
                                additional_input=None):
     deconv = NeuronDeconvolution(model, layer)
     attributions = deconv.attribute(
         test_input,
         neuron_index=neuron_index,
         additional_forward_args=additional_input,
     )
     for i in range(len(test_input)):
         assertTensorAlmostEqual(self,
                                 attributions[i],
                                 expected[i],
                                 delta=0.01)