-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
26 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,25 @@ | ||
## Import modules | ||
```python | ||
import funs.util as util | ||
import funs.engine as engine | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
``` | ||
## Initialize random number generator | ||
```python | ||
np.random.seed(123) | ||
``` | ||
## Specify dataset & fitting parameters | ||
```python | ||
xdim = 2 | ||
ydim = 30 | ||
numTrials = 50 | ||
trialDur = 200 # in ms | ||
binSize = 20 # in ms | ||
maxEMiter = 100 | ||
dOffset = 1 # controls firing rate | ||
``` | ||
## Sample from the model (simulate a dataset) | ||
```python | ||
training_set = util.dataset( | ||
seed = np.random.randint(10000), | ||
xdim = xdim, | ||
ydim = ydim, | ||
numTrials = numTrials, | ||
trialDur = trialDur, | ||
binSize = binSize, | ||
dOffset = dOffset, | ||
fixTau = True, | ||
fixedTau = np.linspace(0.1,0.5,xdim), | ||
drawSameX = True) | ||
``` | ||
__Output:__ | ||
``` | ||
+------------- Simulated Dataset Options -------------+ | ||
| Dimensionality of Latent State: 2 | | ||
| Dimensionality of Observed State (# neurons): 30 | | ||
| Duration of trials (ms): 200 | | ||
| Size of bins (ms): 20 | | ||
| Number of Trials: 50 | | ||
+-----------------------------------------------------+ | ||
Sampling trial 50 ... | ||
Average firing rate per neuron in this dataset: 65.003 Hz. | ||
``` | ||
## Initialize parameters using Poisson-PCA | ||
```python | ||
initParams = util.initializeParams(xdim, ydim, training_set) | ||
``` | ||
## Fit using vanilla (batch) EM | ||
```python | ||
fitBatch = engine.PPGPFAfit( | ||
experiment = training_set, | ||
initParams = initParams, | ||
inferenceMethod = 'laplace', | ||
EMmode = 'Batch', | ||
maxEMiter = maxEMiter) | ||
``` | ||
__Output:__ | ||
``` | ||
+-------------------- Fit Options --------------------+ | ||
| Dimensionality of Latent State: 2 | | ||
| Dimensionality of Observed State (# neurons): 30 | | ||
| EM mode: Batch | | ||
| Max EM iterations: 100 | | ||
| Inference Method: laplace | | ||
+-----------------------------------------------------+ | ||
Iteration: 100 of 100, nPLL: = -224.6181 | ||
This dataset is a simulated dataset. | ||
Processing performance against ground truth parameters... | ||
``` | ||
# Poisson-GPFA | ||
|
||
This package is written by: | ||
* Hooram Nam, `hooramnam@openmailbox.org` | ||
* Jakob Macke, `jakob.macke@caesar.de` | ||
|
||
This repository contains different methods for the Gaussian process model withPoisson observations. It has been developed and implemented with the goal of modelling spike-train recordings from neural populations, but some of the methods will be applicable more generally. | ||
|
||
In particular, the repository includes methods for | ||
|
||
* Laplace approximation for state-inference | ||
* Variational method for state-inference | ||
* Expectation maximisation for parameter learning, using Laplace or Variational inference | ||
* Full EM, where all available trials are processed in each iteration | ||
* Variants of stochastic EM, where a subset of avilable trials are processed in each iteration | ||
|
||
## Usage | ||
|
||
To get started the the example script either by `python example.py` in bash or`run example.py` inside iPython. The software is developed within the Anaconda python 3 environment. | ||
|
||
If you notice a but, watnt to request a feature, or have a question or feedback, please make use of the issue-tracking capabilities of the repository. We love to hear from people using our code -- please send an email to info@mackelab.org. | ||
|
||
The code in this repository is a work in progress. This work is published under the GNU General Public License. The code is provided "as is" and has not warranty whatsoever. | ||
|
||
|
||
## Fit using online EM | ||
```python | ||
fitOnline = engine.PPGPFAfit( | ||
experiment = training_set, | ||
initParams = initParams, | ||
EMmode = 'Online', | ||
maxEMiter = maxEMiter, | ||
inferenceMethod = 'laplace', | ||
batchSize = 5) | ||
``` | ||
__Output:__ | ||
``` | ||
+-------------------- Fit Options --------------------+ | ||
| Dimensionality of Latent State: 2 | | ||
| Dimensionality of Observed State (# neurons): 30 | | ||
| EM mode: Online | | ||
| Max EM iterations: 100 | | ||
| Inference Method: laplace | | ||
| Online Param Update Method: `diag` | | ||
| Batch size (trials): 5 | | ||
+-----------------------------------------------------+ | ||
Iteration: 100 of 100, nPLL: = -226.2654 | ||
This dataset is a simulated dataset. | ||
Processing performance against ground truth parameters... | ||
``` |
Binary file not shown.
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
Binary file not shown.