EnsembleView
flyvision.network.directories.EnsembleDir ¶
Bases: Directory
Contains many NetworkDirs.
Source code in flyvision/network/directories.py
39 40 41 |
|
flyvision.network.EnsembleView ¶
Bases: Ensemble
A view of an ensemble of trained networks.
This class extends the Ensemble class with visualization and analysis methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path, Iterable, EnsembleDir, Ensemble]
|
Path to the ensemble directory or an existing Ensemble object. |
required |
network_class |
Module
|
The network class to use for instantiation. |
Network
|
root_dir |
Path
|
Root directory for results. |
results_dir
|
connectome_getter |
Callable
|
Function to get the connectome. |
get_avgfilt_connectome
|
checkpoint_mapper |
Callable
|
Function to resolve checkpoints. |
resolve_checkpoints
|
best_checkpoint_fn |
Callable
|
Function to select the best checkpoint. |
best_checkpoint_default_fn
|
best_checkpoint_fn_kwargs |
dict
|
Keyword arguments for best_checkpoint_fn. |
{'validation_subdir': 'validation', 'loss_file_name': 'loss'}
|
recover_fn |
Callable
|
Function to recover the network. |
recover_network
|
try_sort |
bool
|
Whether to try sorting the ensemble. |
False
|
Source code in flyvision/network/ensemble_view.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 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 279 280 |
|
training_loss ¶
training_loss(**kwargs)
Plot training loss curves for the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Additional keyword arguments to pass to plots.loss_curves. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the matplotlib Figure and Axes objects. |
Source code in flyvision/network/ensemble_view.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
validation_loss ¶
validation_loss(
validation_subdir=None, loss_file_name=None, **kwargs
)
Plot validation loss curves for the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validation_subdir |
Optional[str]
|
Subdirectory containing validation data. |
None
|
loss_file_name |
Optional[str]
|
Name of the loss file. |
None
|
**kwargs |
Additional keyword arguments to pass to plots.loss_curves. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the matplotlib Figure and Axes objects. |
Source code in flyvision/network/ensemble_view.py
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 |
|
task_error_histogram ¶
task_error_histogram(**kwargs)
Plot a histogram of the validation losses of the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Additional keyword arguments to pass to plots.histogram. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the matplotlib Figure and Axes objects. |
Source code in flyvision/network/ensemble_view.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
node_parameters ¶
node_parameters(key, max_per_ax=34, **kwargs)
Plot violin plots of node parameters for the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The parameter key to plot. |
required |
max_per_ax |
int
|
Maximum number of violins per axis. |
34
|
**kwargs |
Additional keyword arguments to pass to plots.violins. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, List[Axes]]
|
A tuple containing the matplotlib Figure and a list of Axes objects. |
Source code in flyvision/network/ensemble_view.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
edge_parameters ¶
edge_parameters(key, max_per_ax=120, **kwargs)
Plot violin plots of edge parameters for the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The parameter key to plot. |
required |
max_per_ax |
int
|
Maximum number of violins per axis. |
120
|
**kwargs |
Additional keyword arguments to pass to plots.violins. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, List[Axes]]
|
A tuple containing the matplotlib Figure and a list of Axes objects. |
Source code in flyvision/network/ensemble_view.py
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 |
|
dead_or_alive ¶
dead_or_alive(**kwargs)
Plot a heatmap of dead cells in the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Additional keyword arguments to pass to plots.heatmap. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the matplotlib Figure and Axes objects. |
Source code in flyvision/network/ensemble_view.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
flash_response_index ¶
flash_response_index(cell_types=None, **kwargs)
Plot the flash response indices of the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_types |
Optional[List[str]]
|
List of cell types to include. If None, all cell types are used. |
None
|
**kwargs |
Additional keyword arguments to pass to plot_fris. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
A tuple containing the matplotlib Figure and Axes objects. |
Source code in flyvision/network/ensemble_view.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
direction_selectivity_index ¶
direction_selectivity_index(**kwargs)
Plot the direction selectivity indices of the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Additional keyword arguments to pass to plot_dsis. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Tuple[Axes, Axes]]
|
A tuple containing the matplotlib Figure and a tuple of Axes objects. |
Source code in flyvision/network/ensemble_view.py
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 279 280 |
|
flyvision.network.Ensemble ¶
Bases: dict
Dictionary to a collection of trained networks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path, Iterable, 'EnsembleDir']
|
Path to ensemble directory or list of paths to model directories. Can be a single string, then assumes the path is the root directory as configured by datamate. |
required |
network_class |
Module
|
Class to use for initializing networks. |
Network
|
root_dir |
Path
|
Root directory for model paths. |
results_dir
|
connectome_getter |
Callable
|
Function to get the connectome. |
get_avgfilt_connectome
|
checkpoint_mapper |
Callable
|
Function to map checkpoints. |
resolve_checkpoints
|
best_checkpoint_fn |
Callable
|
Function to determine best checkpoint. |
best_checkpoint_default_fn
|
best_checkpoint_fn_kwargs |
dict
|
Kwargs for best_checkpoint_fn. |
{'validation_subdir': 'validation', 'loss_file_name': 'loss'}
|
recover_fn |
Callable
|
Function to recover network. |
recover_network
|
try_sort |
bool
|
Whether to try to sort the ensemble by validation error. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
names |
List[str]
|
List of model names. |
name |
str
|
Ensemble name. |
path |
Path
|
Path to ensemble directory. |
model_paths |
List[Path]
|
List of paths to model directories. |
dir |
EnsembleDir
|
Directory object for ensemble directory. |
Note
The ensemble is a dynamic dictionary, so you can access the networks in the ensemble by name or index. For example, to access the first network simply do:
ensemble[0]
ensemble['flow/000/0000']
ensemble[0:2]
Source code in flyvision/network/ensemble.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 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 279 280 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 334 335 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
|
__getitem__ ¶
__getitem__(key)
Get item from the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Union[str, int, slice, NDArray, list]
|
Key to access the ensemble. Can be a string, int, slice, NDArray, or list. |
required |
Returns:
Type | Description |
---|---|
Union[NetworkView, 'Ensemble']
|
NetworkView or Ensemble: The requested item or subset of the ensemble. |
Raises:
Type | Description |
---|---|
ValueError
|
If the key is invalid. |
Source code in flyvision/network/ensemble.py
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 |
|
__repr__ ¶
__repr__()
Return a string representation of the Ensemble.
Source code in flyvision/network/ensemble.py
211 212 213 |
|
__dir__ ¶
__dir__()
Return a list of attributes for the Ensemble.
Source code in flyvision/network/ensemble.py
215 216 217 |
|
__len__ ¶
__len__()
Return the number of networks in the Ensemble.
Source code in flyvision/network/ensemble.py
219 220 221 |
|
__iter__ ¶
__iter__()
Iterate over the names of the networks in the Ensemble.
Source code in flyvision/network/ensemble.py
223 224 225 |
|
items ¶
items()
Return an iterator over the (name, NetworkView) pairs in the Ensemble.
Source code in flyvision/network/ensemble.py
227 228 229 |
|
keys ¶
keys()
Return a list of network names in the Ensemble.
Source code in flyvision/network/ensemble.py
231 232 233 |
|
values ¶
values()
Return a list of NetworkViews in the Ensemble.
Source code in flyvision/network/ensemble.py
235 236 237 |
|
check_configs_match ¶
check_configs_match()
Check if the configurations of the networks in the ensemble match.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if all configurations match, False otherwise. |
Source code in flyvision/network/ensemble.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
yield_networks ¶
yield_networks()
Yield initialized networks from the ensemble.
Yields:
Name | Type | Description |
---|---|---|
Network |
Network
|
Initialized network from the ensemble. |
Source code in flyvision/network/ensemble.py
265 266 267 268 269 270 271 272 273 274 |
|
yield_decoders ¶
yield_decoders()
Yield initialized decoders from the ensemble.
Yields:
Type | Description |
---|---|
Module
|
nn.Module: Initialized decoder from the ensemble. |
Source code in flyvision/network/ensemble.py
276 277 278 279 280 281 282 283 284 285 |
|
simulate ¶
simulate(movie_input, dt, fade_in=True)
Simulate the ensemble activity from movie input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
movie_input |
Tensor
|
Tensor with shape (batch_size, n_frames, 1, hexals). |
required |
dt |
float
|
Integration time constant. Warns if dt > 1/50. |
required |
fade_in |
bool
|
Whether to use |
True
|
Yields:
Type | Description |
---|---|
ndarray
|
np.ndarray: Response of each individual network. |
Note
Simulates across batch_size in parallel, which can easily lead to OOM for large batch sizes.
Source code in flyvision/network/ensemble.py
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 |
|
simulate_from_dataset ¶
simulate_from_dataset(
dataset,
dt,
indices=None,
t_pre=1.0,
t_fade_in=0.0,
default_stim_key="lum",
batch_size=1,
central_cell_only=True,
)
Simulate the ensemble activity from a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Dataset to simulate from. |
required | |
dt |
float
|
Integration time constant. |
required |
indices |
Iterable[int]
|
Indices of stimuli to simulate. Defaults to None (all stimuli). |
None
|
t_pre |
float
|
Time before stimulus onset. Defaults to 1.0. |
1.0
|
t_fade_in |
float
|
Fade-in time. Defaults to 0.0. |
0.0
|
default_stim_key |
str
|
Default stimulus key. Defaults to “lum”. |
'lum'
|
batch_size |
int
|
Batch size for simulation. Defaults to 1. |
1
|
central_cell_only |
bool
|
Whether to return only central cells. Defaults to True. |
True
|
Yields:
Type | Description |
---|---|
ndarray
|
np.ndarray: Simulated responses for each network. |
Source code in flyvision/network/ensemble.py
325 326 327 328 329 330 331 332 333 334 335 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 |
|
decode ¶
decode(movie_input, dt)
Decode the ensemble responses with the ensemble decoders.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
movie_input |
Tensor
|
Input movie tensor. |
required |
dt |
float
|
Integration time constant. |
required |
Yields:
Type | Description |
---|---|
ndarray
|
np.ndarray: Decoded responses for each network. |
Source code in flyvision/network/ensemble.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
|
validation_file ¶
validation_file(
validation_subdir=None, loss_file_name=None
)
Return the validation file for each network in the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validation_subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
loss_file_name |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
Tuple[str, str]: Validation subdirectory and loss file name. |
Source code in flyvision/network/ensemble.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
sort ¶
sort(validation_subdir=None, loss_file_name=None)
Sort the ensemble by validation loss.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validation_subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
loss_file_name |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Source code in flyvision/network/ensemble.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
argsort ¶
argsort(validation_subdir=None, loss_file_name=None)
Return the indices that would sort the ensemble by validation loss.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validation_subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
loss_file_name |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Indices that would sort the ensemble. |
Source code in flyvision/network/ensemble.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
zorder ¶
zorder(validation_subdir=None, loss_file_name=None)
Return the z-order of the ensemble based on validation loss.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validation_subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
loss_file_name |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Z-order of the ensemble. |
Source code in flyvision/network/ensemble.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
validation_losses ¶
validation_losses(subdir=None, file=None)
Return a list of validation losses for each network in the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
file |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Validation losses for each network. |
Source code in flyvision/network/ensemble.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
min_validation_losses ¶
min_validation_losses(subdir=None, file=None)
Return the minimum validation loss of the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subdir |
Optional[str]
|
Subdirectory for validation files. Defaults to None. |
None
|
file |
Optional[str]
|
Name of the loss file. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Minimum validation losses for each network. |
Source code in flyvision/network/ensemble.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
rank_by_validation_error ¶
rank_by_validation_error(reverse=False)
Temporarily sort the ensemble based on validation error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reverse |
bool
|
Whether to sort in descending order. Defaults to False. |
False
|
Yields:
Type | Description |
---|---|
None |
Source code in flyvision/network/ensemble.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
|
ratio ¶
ratio(best=None, worst=None)
Temporarily filter the ensemble by a ratio of best or worst performing models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
best |
Optional[float]
|
Ratio of best performing models to keep. Defaults to None. |
None
|
worst |
Optional[float]
|
Ratio of worst performing models to keep. Defaults to None. |
None
|
Yields:
Type | Description |
---|---|
None |
Raises:
Type | Description |
---|---|
ValueError
|
If best and worst sum to more than 1. |
Source code in flyvision/network/ensemble.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
|
select_items ¶
select_items(indices)
Temporarily filter the ensemble by a list of indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indices |
List[int]
|
List of indices to select. |
required |
Yields:
Type | Description |
---|---|
None |
Raises:
Type | Description |
---|---|
ValueError
|
If indices are invalid. |
Source code in flyvision/network/ensemble.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
|
task_error ¶
task_error(
cmap="Blues_r", truncate=None, vmin=None, vmax=None
)
Return a TaskError object for the ensemble.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap |
Union[str, Colormap]
|
Colormap to use. Defaults to “Blues_r”. |
'Blues_r'
|
truncate |
Optional[Dict[str, Union[float, int]]]
|
Dictionary to truncate the colormap. Defaults to None. |
None
|
vmin |
Optional[float]
|
Minimum value for normalization. Defaults to None. |
None
|
vmax |
Optional[float]
|
Maximum value for normalization. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
TaskError |
'TaskError'
|
Object containing validation losses, colors, colormap, norm, and scalar mapper. |
Source code in flyvision/network/ensemble.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
|
parameters ¶
parameters()
Return the parameters of the ensemble.
Returns:
Type | Description |
---|---|
Dict[str, ndarray]
|
Dict[str, np.ndarray]: Dictionary of parameter arrays. |
Source code in flyvision/network/ensemble.py
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
|
parameter_keys ¶
parameter_keys()
Return the keys of the parameters of the ensemble.
Returns:
Type | Description |
---|---|
Dict[str, List[str]]
|
Dict[str, List[str]]: Dictionary of parameter keys. |
Source code in flyvision/network/ensemble.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
|
flash_responses ¶
flash_responses(*args, **kwargs)
Generate flash responses.
Source code in flyvision/network/ensemble.py
728 729 730 731 732 |
|
moving_edge_responses ¶
moving_edge_responses(*args, **kwargs)
Generate moving edge responses.
Source code in flyvision/network/ensemble.py
734 735 736 737 738 |
|
moving_bar_responses ¶
moving_bar_responses(*args, **kwargs)
Generate moving bar responses.
Source code in flyvision/network/ensemble.py
740 741 742 743 744 |
|
naturalistic_stimuli_responses ¶
naturalistic_stimuli_responses(*args, **kwargs)
Generate naturalistic stimuli responses.
Source code in flyvision/network/ensemble.py
746 747 748 749 750 |
|
central_impulses_responses ¶
central_impulses_responses(*args, **kwargs)
Generate central ommatidium impulses responses.
Source code in flyvision/network/ensemble.py
752 753 754 755 756 |
|
spatial_impulses_responses ¶
spatial_impulses_responses(*args, **kwargs)
Generate spatial ommatidium impulses responses.
Source code in flyvision/network/ensemble.py
758 759 760 761 762 |
|
moving_edge_currents ¶
moving_edge_currents(*args, **kwargs)
Generate moving edge currents.
Source code in flyvision/network/ensemble.py
764 765 766 767 768 769 770 |
|
clustering ¶
clustering(cell_type)
Return the clustering of the ensemble for a given cell type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_type |
The cell type to cluster. |
required |
Returns:
Name | Type | Description |
---|---|---|
GaussianMixtureClustering |
GaussianMixtureClustering
|
Clustering object for the given cell type. |
Raises:
Type | Description |
---|---|
ValueError
|
If clustering is not available in context. |
Source code in flyvision/network/ensemble.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
|
cluster_indices ¶
cluster_indices(cell_type)
Clusters from responses to naturalistic stimuli of the given cell type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_type |
str
|
The cell type to return the clusters for. |
required |
Returns:
Type | Description |
---|---|
Dict[int, NDArray[int]]
|
Dict[int, NDArray[int]]: Keys are the cluster ids and the values are the |
Dict[int, NDArray[int]]
|
model indices in the ensemble. |
Example
ensemble = Ensemble("path/to/ensemble")
cluster_indices = ensemble.cluster_indices("T4a")
first_cluster = ensemble[cluster_indices[0]]
Raises:
Type | Description |
---|---|
ValueError
|
If stored clustering does not match ensemble. |
Source code in flyvision/network/ensemble.py
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
|
responses_norm ¶
responses_norm(rectified=False)
Compute the norm of responses to naturalistic stimuli.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rectified |
bool
|
Whether to rectify responses before computing norm. |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Norm of responses for each network. |
Source code in flyvision/network/ensemble.py
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
|