Ejemplo n.º 1
0
    def _call(
            self,
            model_identifier,
            benchmark_identifier,  # storage fields
            model,
            benchmark,
            layers,
            prerun=False):
        if prerun:
            # pre-run activations together to avoid running every layer separately
            model(layers=layers, stimuli=benchmark._assembly.stimulus_set)

        for layer in tqdm(layers, desc="layers"):
            layer_model = LayerMappedModel(
                identifier=f"{model_identifier}-{layer}",
                activations_model=model,
                region_layer_map={benchmark.region: layer})
            layer_model = TemporalIgnore(layer_model)
            layer_model.start_recording(benchmark.region,
                                        time_bins=benchmark.timebins)
            layer_model.look_at(benchmark._assembly.stimulus_set)
Ejemplo n.º 2
0
    def test_commit(self, model_ctr, layers, region):
        activations_model = model_ctr()
        layer_model = LayerMappedModel(identifier=activations_model.identifier, activations_model=activations_model,
                                       region_layer_map={region: layers})

        layer_model.start_recording(region)
        stimulus_set = StimulusSet([{'image_id': 'test'}])
        stimulus_set.image_paths = {'test': os.path.join(os.path.dirname(__file__), 'rgb1.jpg')}
        stimulus_set.identifier = self.__class__.__name__
        predictions = layer_model.look_at(stimulus_set)
        assert set(predictions['region'].values) == {region}
        assert set(predictions['layer'].values) == {layers} if isinstance(layers, str) else set(layers)