-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetails
13 lines (7 loc) · 2.79 KB
/
Details
1
2
3
4
5
6
7
8
9
10
11
12
13
This is a Python code that trains and tests a model of the olfactory system for odor classification. The code imports four modules: "epl", "OSN", "readout", and "plots". The "epl" module is used for the initialization of the model and the implementation of the EPL learning rule. The "OSN" module is used for encoding odor stimuli into a format that can be processed by the model. The "readout" module is used for reading out the response of the model to odor stimuli and computing a similarity matrix that can be used for odor classification. The "plots" module is used for visualizing the response of the model and the similarity matrix.
The code starts by loading the training and test data from a binary file using the "pickle" module. The training data consists of an array of arrays, where each inner array represents the response of the olfactory sensory neurons (OSNs) to a specific odor stimulus. The test data consists of an array of individual odor stimuli. The number of odors to train and test are printed to the console.
The model is initialized with the number of mitral cells (MCs) in the model, which is equal to the number of OSNs in the data, and the number of granule cells (GCs) per neurogenesis, which determines the number of GCs in the model. The number of GCs in the model is calculated as the product of the number of MCs, the number of GCs per neurogenesis, and the number of odors. The "epl" module is then used to create an instance of the model.
The "sniff" function is defined to simulate the process of odor stimulation and processing by the model. It takes an odor stimulus as input and encodes it using the "OSN" module. It then updates the state of the model for a specified number of gamma cycles. The "learn_flag" parameter determines whether the model should learn during the simulation or not. The "nGammaPerOdor" parameter specifies the number of gamma cycles per odor, and the "gPeriod" parameter specifies the duration of each gamma cycle.
The code then trains the model on the training data by iterating over each odor stimulus, simulating odor stimulation and processing using the "sniff" function, and invoking neurogenesis in the GC layer using the "invokeNeurogenesis" method of the "GClayer" object. After neurogenesis, the model is simulated again without learning.
The model is then tested on the test data by iterating over each odor stimulus, simulating odor stimulation and processing using the "sniff" function without learning. The number of odors tested is printed to the console.
The "readout" module is then used to read out the response of the model to the test odors and compute a similarity matrix using the "sMatrix" variable. The "plots" module is then used to visualize the response of the model and the similarity matrix using the "plotFigure3b" and "plotFigure3d" functions, respectively.