-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sw/bs_version_update
- Loading branch information
Showing
127 changed files
with
2,160 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from brainscore_vision import benchmark_registry | ||
from . import benchmark | ||
|
||
# behavioral benchmarks | ||
benchmark_registry['Scialom2024_rgbBehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('rgb') | ||
benchmark_registry['Scialom2024_contoursBehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('contours') | ||
benchmark_registry['Scialom2024_phosphenes-12BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-12') | ||
benchmark_registry['Scialom2024_phosphenes-16BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-16') | ||
benchmark_registry['Scialom2024_phosphenes-21BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-21') | ||
benchmark_registry['Scialom2024_phosphenes-27BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-27') | ||
benchmark_registry['Scialom2024_phosphenes-35BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-35') | ||
benchmark_registry['Scialom2024_phosphenes-46BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-46') | ||
benchmark_registry['Scialom2024_phosphenes-59BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-59') | ||
benchmark_registry['Scialom2024_phosphenes-77BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-77') | ||
benchmark_registry['Scialom2024_phosphenes-100BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('phosphenes-100') | ||
benchmark_registry['Scialom2024_segments-12BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-12') | ||
benchmark_registry['Scialom2024_segments-16BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-16') | ||
benchmark_registry['Scialom2024_segments-21BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-21') | ||
benchmark_registry['Scialom2024_segments-27BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-27') | ||
benchmark_registry['Scialom2024_segments-35BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-35') | ||
benchmark_registry['Scialom2024_segments-46BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-46') | ||
benchmark_registry['Scialom2024_segments-59BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-59') | ||
benchmark_registry['Scialom2024_segments-77BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-77') | ||
benchmark_registry['Scialom2024_segments-100BehavioralAccuracyDistance'] = lambda: benchmark._Scialom2024BehavioralAccuracyDistance('segments-100') | ||
|
||
# composites | ||
benchmark_registry['Scialom2024_phosphenes-allBehavioralErrorConsistency'] = lambda: benchmark._Scialom2024BehavioralErrorConsistency('phosphenes-all') | ||
benchmark_registry['Scialom2024_segments-allBehavioralErrorConsistency'] = lambda: benchmark._Scialom2024BehavioralErrorConsistency('segments-all') | ||
|
||
# engineering benchmarks | ||
benchmark_registry['Scialom2024_rgbEngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('rgb') | ||
benchmark_registry['Scialom2024_contoursEngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('contours') | ||
benchmark_registry['Scialom2024_phosphenes-12EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-12') | ||
benchmark_registry['Scialom2024_phosphenes-16EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-16') | ||
benchmark_registry['Scialom2024_phosphenes-21EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-21') | ||
benchmark_registry['Scialom2024_phosphenes-27EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-27') | ||
benchmark_registry['Scialom2024_phosphenes-35EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-35') | ||
benchmark_registry['Scialom2024_phosphenes-46EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-46') | ||
benchmark_registry['Scialom2024_phosphenes-59EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-59') | ||
benchmark_registry['Scialom2024_phosphenes-77EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-77') | ||
benchmark_registry['Scialom2024_phosphenes-100EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('phosphenes-100') | ||
benchmark_registry['Scialom2024_segments-12EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-12') | ||
benchmark_registry['Scialom2024_segments-16EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-16') | ||
benchmark_registry['Scialom2024_segments-21EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-21') | ||
benchmark_registry['Scialom2024_segments-27EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-27') | ||
benchmark_registry['Scialom2024_segments-35EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-35') | ||
benchmark_registry['Scialom2024_segments-46EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-46') | ||
benchmark_registry['Scialom2024_segments-59EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-59') | ||
benchmark_registry['Scialom2024_segments-77EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-77') | ||
benchmark_registry['Scialom2024_segments-100EngineeringAccuracy'] = lambda: benchmark._Scialom2024EngineeringAccuracy('segments-100') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import numpy as np | ||
|
||
import brainscore_vision | ||
from brainio.assemblies import BehavioralAssembly | ||
from brainscore_vision import load_dataset, load_metric | ||
from brainscore_vision.benchmark_helpers.screen import place_on_screen | ||
from brainscore_vision.benchmarks import BenchmarkBase | ||
from brainscore_vision.metrics import Score | ||
from brainscore_vision.model_interface import BrainModel | ||
from brainscore_vision.utils import LazyLoad | ||
|
||
BIBTEX = "" # to appear in a future article | ||
|
||
|
||
class _Scialom2024BehavioralErrorConsistency(BenchmarkBase): | ||
def __init__(self, dataset): | ||
self._metric = load_metric('error_consistency') | ||
self._assembly = LazyLoad(lambda: load_assembly(dataset)) | ||
self._visual_degrees = 8 | ||
self._number_of_trials = 1 | ||
|
||
super(_Scialom2024BehavioralErrorConsistency, self).__init__( | ||
identifier=f'Scialom2024_{dataset}-error_consistency', version=1, | ||
ceiling_func=lambda: self._metric.ceiling(self._assembly), | ||
parent='Scialom2024', | ||
bibtex=BIBTEX) | ||
|
||
def __call__(self, candidate: BrainModel): | ||
choice_labels = set(self._assembly['truth'].values) | ||
choice_labels = list(sorted(choice_labels)) | ||
candidate.start_task(BrainModel.Task.label, choice_labels) | ||
stimulus_set = place_on_screen(self._assembly.stimulus_set, target_visual_degrees=candidate.visual_degrees(), | ||
source_visual_degrees=self._visual_degrees) | ||
labels = candidate.look_at(stimulus_set, number_of_trials=self._number_of_trials) | ||
raw_score = self._metric(labels, self._assembly) | ||
ceiling = self.ceiling | ||
score = raw_score / ceiling | ||
score.attrs['raw'] = raw_score | ||
score.attrs['ceiling'] = ceiling | ||
return score | ||
|
||
|
||
class _Scialom2024BehavioralAccuracyDistance(BenchmarkBase): | ||
# behavioral benchmark | ||
def __init__(self, dataset): | ||
self._metric = load_metric('accuracy_distance') | ||
self._assembly = LazyLoad(lambda: load_assembly(dataset)) | ||
super(_Scialom2024BehavioralAccuracyDistance, self).__init__( | ||
identifier=f'Scialom2024_{dataset}-behavioral_accuracy', version=1, | ||
ceiling_func=lambda: self._metric.ceiling(self._assembly), | ||
parent='Scialom2024', | ||
bibtex=BIBTEX) | ||
|
||
def __call__(self, candidate: BrainModel): | ||
choice_labels = set(self._assembly.stimulus_set['truth'].values) | ||
choice_labels = list(sorted(choice_labels)) | ||
candidate.start_task(BrainModel.Task.label, choice_labels) | ||
labels = candidate.look_at(self._assembly.stimulus_set, number_of_trials=1) | ||
raw_score = self._metric(labels, target=self._assembly) | ||
ceiling = self.ceiling | ||
score = raw_score / ceiling | ||
# ensure score <= 1.0 | ||
if score.values > 1: | ||
score = Score(np.array(1.)) | ||
score.attrs['raw'] = raw_score | ||
score.attrs['ceiling'] = ceiling | ||
return score | ||
|
||
|
||
class _Scialom2024EngineeringAccuracy(BenchmarkBase): | ||
# engineering/ML benchmark | ||
def __init__(self, dataset): | ||
self._metric = load_metric('accuracy') | ||
# no lazyload because needed in candidate.look_at() | ||
self._stimulus_set = load_assembly(dataset).stimulus_set | ||
super(_Scialom2024EngineeringAccuracy, self).__init__( | ||
identifier=f'Scialom2024_{dataset}-engineering_accuracy', version=1, | ||
ceiling_func=lambda: Score(1), | ||
parent='Scialom2024-top1', | ||
bibtex=BIBTEX) | ||
|
||
def __call__(self, candidate: BrainModel): | ||
choice_labels = set(self._stimulus_set['truth'].values) | ||
choice_labels = list(sorted(choice_labels)) | ||
candidate.start_task(BrainModel.Task.label, choice_labels) | ||
labels = candidate.look_at(self._stimulus_set, number_of_trials=10) | ||
raw_score = self._metric(labels, target=self._stimulus_set['truth'].values) | ||
ceiling = Score(np.array(1.)) | ||
score = raw_score / ceiling | ||
score.attrs['raw'] = raw_score | ||
score.attrs['ceiling'] = ceiling | ||
return score | ||
|
||
|
||
def load_assembly(dataset: str) -> BehavioralAssembly: | ||
assembly = brainscore_vision.load_dataset(f'Scialom2024_{dataset}') | ||
return assembly |
Oops, something went wrong.