Playground Gradient Symbolic Computation (grascom)
This project is a Python3 implementation of the GSC (Smolensky & Legendre 2016, Cho, Goldrick & Smolensky 2014,2020), a psychogically plausible, continuous-state, continuous-time stochastic dynamical-system model of input processing. The main interest for GSC comes from the fact that it makes possible to join classical symbolic cognitive theory with neural computation.
The main inspiration for the code comes from the MATLAB program LDNet (v. 1.5), of which this repo is a python translation. Main differences of grascom compared with LDNet:
- It uses the Pytorch library to deal with high-dimensional tensors
- It lacks the sequential mode and 3d Animation (for now)
- Plotting using seaborn
LDNet was originally developed to model phenomena such as voicing neutralization or twister production. The idea here is to use the GSC to model linguistic phenomena such as allomorphy or sandhi (external and internal), where we could assume that much of chaotic surface forms are just the consequence of blends of multiple underlying representations, each partially activated. See the Jupyter-notebook for a concrete instantiation. At moment very simplistic positional roles were used. I'm thinking about implementing some kind of span (or brick) roles.
TPR_example
: How to represent symbolic structures using the Tensor Product Representationexample
: GSC run on a toy-example (Sanskrit allomorphy: bhud vs budh aka Grassmann's Law)
Optimal weights (for constraints) and activation values (for inputs) can be found using either mathematical Optimization or a simple learning algorithm (as suggested in E. Rosen (2019)). See the folder Optimization
for a simple implementation.
disclaimer : The project is a work in progress in a early phase and was created with the main goal to practice with the GSC framework and develop an intuition, how the GSC works. There are for sure many parts that could be improved or present some bugs. Feel free to use this project, open an issue or make suggestions. Any help would be greatly appreciated.
grascom
│ LICENSE
│ main.py
│ Readme.md
│ requirements.txt
│
├───data
│ │ full_traces.mat
│ │ full_traces.pt
│ │ initialized_mats.mat
│ │ inp2.csv
│ │ inp_pandas.csv
│ │ params.mat
│ │ params.pt
│ │ stimuli_summary.txt
│ │ summary.txt
│ │
│ └───plots
│ harmonized_input.png
│ Input_gradient_activation.png
│ plotsFrequency_ep1_stimulus_0.png
│ plotsHarmonies_ep1_stimulus_0.png
│ random_activation.png
├───docs
│ LDnet1.5 Manual.pdf
│ Readme.md
│
├───examples
│ example.ipynb
│ tableaux.xlsx
│ TPR_example.ipynb
│
├───Optimization
│ optimizeWA..pdf
│ optimizeWA.jl
│
└───src
│
├───classes
│ bindings.py
│ Bowl.py
│ Grammar.py
│ utilFunc.py
└───gsc
gsc_network.py
plotting.py
data/
: This folder contains the external inputs, logs and summaries.data/inp.csv
: contains the training data. The first col (id) separates different inputs, same index = same word. The other columns give the activation values for each filler in the word for each role in the grammar. The csv is read into the grammar using thepandas
library.*.mat
,*.pt
: backup files in Matlab and Pytorch format.
src/
:classes/
: A collection of Python classes, to process single components of the GSC model. These include the following classes: Roles, Fillers, Bindings, HarmonicGrammar, Bowl.utilfunc.py
: A couple of general purpose auxiliary functions.gsc/
: The folder contains the main class of the project: the GSCNet and the class Plot for plotting the tracesmain.py
: the entry point for simulations. Here the user can declare a set of fillers and roles, (optionally) together with filler symmetries and Harmonic Constraints. These variables are used to initialize and run the network.- Notebooks : Example and visualizations.
see requirement.txt
N.B: Use the last stable version of PyTorch (1.8.0) since only this version supports some advanced linalg operations (eigenvalues computation, Kronecker product etc..)
- Cho, Mathis & Smolensky (2014) - Optimization and Quantization in Gradient Symbolic Systems
- Cho, Goldrick & Smolensky (2017) - Incremental parsing in a continuous dynamical system
- Cho, Goldrick & Smolensky (2020) .Parallel parsing in a Gradient Symbolic Computation parser
See under "Issues".
Create a JupyterNotebook (better for visualizing)- Implement Span Roles/brick roles to represent recursive structure?
- Implement quantization policies (different bowl_strengths for different timesteps)
- Start documentation
- Improve plots, add other plotting functions
- Test more complex input data
- Move the tensors to CUDA to improve speed.
- 3d animation / Visualize Quantization
- Check clamping techniques (constant value? Projection matrix? input activations?)
- GSC-learning implementation
- Possible starting points:
- GSR Learning by C. Cantwell
- Possible starting points: