BayesianNeuralFieldVI¤
Bases: BayesianNeuralFieldEstimator
Fits models using stochastic ensembles of surrogate posteriors from VI.
Implementation of BayesianNeuralFieldEstimator using variational inference (VI).
Source code in bayesnf/spatiotemporal.py
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 |
|
fit
¤
fit(table, seed, ensemble_size=16, learning_rate=0.01, num_epochs=1000, sample_size_posterior=30, sample_size_divergence=5, kl_weight=0.1, batch_size=None)
Run inference using stochastic variational inference ensembles.
PARAMETER | DESCRIPTION |
---|---|
table |
See documentation of
TYPE:
|
seed |
The jax random key.
TYPE:
|
ensemble_size |
Number of particles (i.e., surrogate posteriors)
in the ensemble, per device. The available devices can be found
via
TYPE:
|
learning_rate |
Learning rate for SGD.
TYPE:
|
num_epochs |
Number of full epochs through the training data.
TYPE:
|
sample_size_posterior |
Number of samples of "posterior" model parameters draw from each surrogate posterior when making predictions.
TYPE:
|
sample_size_divergence |
number of Monte Carlo samples to use in
estimating the variational divergence. Larger values may stabilize
the optimization, but at higher cost per step in time and memory.
See
TYPE:
|
kl_weight |
Weighting of the KL divergence term in VI. The
goal is to find a surrogate posterior
Reference
TYPE:
|
batch_size |
If specified, the log probability in each
step of variational inference is computed on a batch of this size.
Default is
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BayesianNeuralFieldEstimator
|
Instance of self. |
Source code in bayesnf/spatiotemporal.py
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 |
|