computational_choice_model
🗿
Computational models of human choice behavior.
The SPoSE
model is inspired by Hebart et al. (Nat. Hum Beh., 2020), see Fig.1c.
The VICE
model is taken from Muttenthaler et al. (arXiv, 2022)
VICE or SPoSE
'VICE rivals or outperforms its predecessor, SPoSE, at predicting human behavior in the odd-one-out triplet task. Furthermore, VICE's object representations are more reproducible and consistent across random initializations.' - Muttenthaler et al. (arXiv, 2022)
Other computational embedding models are in facesim3d.modeling.VGG
.
Functions:
Name | Description |
---|---|
display_representative_faces |
Display representative faces for the first |
extract_faces_for_spose_dimensions |
Extract the first |
extract_faces_for_vice_dimensions |
Extract the first |
plot_weight_matrix |
Plot the weight (i.e., |
prepare_data_for_spose_and_vice |
Prepare data for |
display_representative_faces
🗿
display_representative_faces(
face_dim_idx_mat: ndarray,
pilot: bool = PILOT,
as_grid: bool = True,
title: str | None = None,
dim_indices: list | None = None,
save_path: str | Path | None = None,
) -> None
Display representative faces for the first m
dimensions of the trained sparse model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face_dim_idx_mat
|
ndarray
|
nxm matrix of indices in representative faces per dimension |
required |
pilot
|
bool
|
True: use pilot data |
PILOT
|
as_grid
|
bool
|
plot as image grid |
True
|
title
|
str | None
|
Image or figure title |
None
|
dim_indices
|
list | None
|
list of dimension indices to display |
None
|
save_path
|
str | Path | None
|
if the path is given, save figure |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in code/facesim3d/modeling/computational_choice_model.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
extract_faces_for_spose_dimensions
🗿
extract_faces_for_spose_dimensions(
session: str,
n_face: int | None = None,
m_dims: int | None = None,
pilot: bool = PILOT,
return_path: bool = False,
**kwargs
) -> ndarray | tuple[ndarray, str]
Extract the first n
most representative faces for the first m
dimensions of the trained SPoSE model.
See Hebart et al. (2020), caption of Fig. 2:
Quote
'The images reflect the objects with the highest weights along those dimensions.'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
str
|
"2D", OR "3D" |
required |
n_face
|
int | None
|
[int] restrict the number of faces OR [None] all faces are returned |
None
|
m_dims
|
int | None
|
[int] restrict the number of dimensions (or weights) in the SPoSE model OR [None] all dimensions are returned |
None
|
pilot
|
bool
|
True: use pilot data |
PILOT
|
return_path
|
bool
|
True: return the path to the weights-file |
False
|
Returns:
Type | Description |
---|---|
ndarray | tuple[ndarray, str]
|
indices of representative faces |
Source code in code/facesim3d/modeling/computational_choice_model.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
extract_faces_for_vice_dimensions
🗿
extract_faces_for_vice_dimensions(
session: str,
n_face: int | None = None,
m_dims: int | None = None,
pilot: bool = PILOT,
pruned: bool = True,
return_path: bool = False,
param_path: str | None = "",
) -> ndarray | tuple[ndarray, str]
Extract the first n
most representative faces for the first m
dimensions of the trained VICE model.
See Muttenthaler et al. (arXiv, 2022), p.19, Section F "Interpretability":
Quote
'Objects were sorted in descending order according to their absolute embedding value.'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
str
|
"2D", OR "3D" |
required |
n_face
|
int | None
|
[int] restrict the number of faces OR [None] all faces are returned |
None
|
m_dims
|
int | None
|
[int] restrict the number of dimensions (or weights) of the VICE model OR [None] all dimensions are returned |
None
|
pilot
|
bool
|
True: use pilot data |
PILOT
|
pruned
|
bool
|
True: return the pruned parameters |
True
|
return_path
|
bool
|
True: return path to the parameter file |
False
|
param_path
|
str | None
|
path to weight file, defined by the corresponding VICE params (after /[session]/..) |
''
|
Returns:
Type | Description |
---|---|
ndarray | tuple[ndarray, str]
|
indices of representative faces |
Source code in code/facesim3d/modeling/computational_choice_model.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
plot_weight_matrix
🗿
plot_weight_matrix(
weights: ndarray,
norm: bool,
fig_name: str,
save: bool = False,
save_path: str | Path | None = "",
)
Plot the weight (i.e., m
-dimensional embedding) matrix of VICE
| SPoSE
.
Source code in code/facesim3d/modeling/computational_choice_model.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
prepare_data_for_spose_and_vice
🗿
prepare_data_for_spose_and_vice(
session: str,
percentage: int | None = None,
gender: bool | str = False,
pilot: bool = PILOT,
) -> None
Prepare data for SPoSE
& VICE
models.
Quote
(...) triplets are expected to be in the format N x 3, where N = number of trials (e.g., 100k) and
3 refers to the triplets, where col_0 = anchor_1, col_1 = anchor_2, col_2 = odd one out.
Triplet data must be split into train and test splits, and named train_90.txt
and test_10.txt
,
respectively.
For hyperparameter tuning, prepare only a percentage of the data.
For more information, see the repos of: SPoSE & VICE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
str
|
'2D', OR '3D' |
required |
percentage
|
int | None
|
percentage of data to use (e.g., 10, 20, ...) |
None
|
gender
|
bool | str
|
True: use only triplets of the same gender, respectively. Compute recursively for both genders. OR str: specify the gender 'female' or 'male'. |
False
|
pilot
|
bool
|
True: use pilot data |
PILOT
|
Source code in code/facesim3d/modeling/computational_choice_model.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|