{"id":13686196,"url":"https://github.com/hbrouwer/mesh","last_synced_at":"2026-04-02T17:48:19.634Z","repository":{"id":3062127,"uuid":"4084472","full_name":"hbrouwer/mesh","owner":"hbrouwer","description":"a lightweight and versatile artificial neural network simulator","archived":false,"fork":false,"pushed_at":"2025-01-03T10:44:24.000Z","size":1314,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T11:39:26.863Z","etag":null,"topics":["backpropagation","cognitive-science","connectionism","lightweight","neural-networks","simulator"],"latest_commit_sha":null,"homepage":"https://github.com/hbrouwer/mesh","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hbrouwer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-20T08:14:50.000Z","updated_at":"2025-01-03T10:44:28.000Z","dependencies_parsed_at":"2024-01-14T15:26:48.664Z","dependency_job_id":"5bc28ac8-7f34-422a-8aef-0da284ac42b3","html_url":"https://github.com/hbrouwer/mesh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbrouwer%2Fmesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbrouwer%2Fmesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbrouwer%2Fmesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbrouwer%2Fmesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hbrouwer","download_url":"https://codeload.github.com/hbrouwer/mesh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251852597,"owners_count":21654434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backpropagation","cognitive-science","connectionism","lightweight","neural-networks","simulator"],"created_at":"2024-08-02T15:00:22.676Z","updated_at":"2026-04-02T17:48:18.448Z","avatar_url":"https://github.com/hbrouwer.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"```\n         ______\n    __---   )  --_      - - - - - - - - - - - - - - - - - - - - - - - - -\n  --       /      -_\n /     o  (         )   Mesh: https://github.com/hbrouwer/mesh\n(     o   ____  o    )  (c) 2012-2022 Harm Brouwer \u003cme@hbrouwer.eu\u003e\n(    o _--     o      )\n (____/       o _____)  Licensed under the Apache License, Version 2.0\n      (____  ---  )\n           \\ \\-__/      - - - - - - - - - - - - - - - - - - - - - - - - -\n```\n\n# Mesh\n\nMesh is a lightweight and versatile artificial neural network simulator,\nprimarily designed as a general-purpose backpropagation (through time)\nsimulator with flexibility and extensibility in mind.\n\n[![build](https://github.com/hbrouwer/mesh/actions/workflows/build.yml/badge.svg)](https://github.com/hbrouwer/mesh/actions/workflows/build.yml)\n\n## Features\n\nMesh comes with support for:\n\n* **Different architectures:** feed forward networks (`ffn`), simple\n  recurrent networks (`srn`) (Elman, 1990), and recurrent neural networks\n  (`rnn`);\n\n* **Training algorithms:** backpropagation (`bp`) (Rumelhart et al., 1986a)\n  and backpropagation through time (`bptt`) (Rumelhart et al., 1986b);\n\n* **Weight update algorithms:** steepest/gradient descent (`steepest`),\n  bounded steepest descent (`bounded`) (Rohde, 2002), four flavours of\n  resilient propagation (`rprop+`, `rprop-`, `irprop+`, and `irprop-`) (Igel\n  \u0026 Husken, 2000), quickprop (`qprop`) (Fahlman, 1988), and delta-bar-delta\n  (`dbd`) (Jacobs, 1988);\n\n* **Activation functions:** logistic (sigmoid)  (`logistic`), bipolar\n  sigmoid (`bipolar_sigmoid`), softmax (`softmax`), hyperbolic tangent\n  (`tanh`), linear (`linear`), (bounded) recitified linear (`relu`), leaky\n  rectified linear (`leaky_relu`), and exponential linear (`elu`);\n\n* **Error functions:** sum squared error (`sum_of_squares`) , cross entropy\n  error (`cross_entropy`), and Kullback-Leibler divergence (`divergence`);\n\n* **Weight randomization algorithms:** gaussian (`gaussian`), uniform range\n  (`range`), Nguyen-Widrow (`nguyen_windrow`) (Nguyen \u0026 Widrow, 1990),\n  Fan-In (`fan_in`), and binary (`binary`).\n\n* **Multithreading** (through [OpenMP](https://www.openmp.org/));\n\n* A module for navigating **propositional meaning spaces**: meaning spaces\n  derived from the Distributed Situation-state Space (DSS) model (Frank et\n  al., 2003) and Distributional Formal Semantics (DFS) (Venhuizen et al.,\n  2021);\n\n* A module for modeling **electrophysiological correlates**: the N400 and\n  P600 components of the Event-Related brain Potentials (ERP) signal\n  (Brouwer, 2014; Brouwer et al., 2017);\n\n* **Pretty printing** of vectors and matrices (through ANSI escape codes);\n\n* And finally, it is **dependency-free**: you only need a C99-compliant\n  (and for multithreading OpenMP-enabled) compiler to build Mesh.\n\n## Why Mesh?\n\n\u003e \"What I cannot create, I do not understand“ -Richard Feynman\n\n**Is Mesh the new PyTorch or TensorFlow?** No, Mesh is **not** the next\n[PyTorch](https://pytorch.org/) or\n[TensorFlow](https://www.tensorflow.org/). Mesh is a simulator that focuses\non traditional connectionist / Parallel Distributed Processing (PDP)\narchitectures and learning algorithms (in the tradition of simulators like\n[Tlearn](https://crl.ucsd.edu/innate/tlearn.html) and\n[Lens](https://ni.cmu.edu/~plaut/Lens/Manual/), among others). It was\ndeveloped along with my PhD dissertation in cognitive neuroscience\n([Brouwer, 2014](https://hbrouwer.github.io/papers/Brouwer2014ElectrophysiologyLanguage.pdf)),\nin which I used it to build a neurocomputational model of the\nelectrophysiology of language comprehension (Brouwer et al., 2017). Mesh is\na one-man show; I started developing Mesh before the deep learning\nrevolution, and hence before large-scale deep learning frameworks like\nPyTorch and TensorFlow, backed by\n[Facebook](https://www.facebook.com/)/[Meta](https://about.facebook.com/meta)\nand [Google](https://www.google.com/), respectively, became available.\n\n**I learned a lot implementing Mesh:** I built Mesh from scratch using\nclassical papers as technical references. I have waded through many slides,\nbooks, and websites, in order to put the different pieces together. Again\nthis was prior to the deep learning revolution, and hence prior to the\nwealth of information that has become available over the last few years.\nIndeed, as the late Jeff Elman (author of\n[Tlearn](https://crl.ucsd.edu/innate/tlearn.html)) pointed out to me:\nI learned an enormous amount about neural networks by implementing Mesh, and\nfor that reason alone it has been worthwhile.\n\n**Mesh is lightweight yet versatile:** We use Mesh on a daily basis to run\ncognitive models of human language comprehension. In Brouwer et al. (2017),\nfor instance, it is used to model electrophysiological correlates of online\ncomprehension, and in Venhuizen et al. (2021) we use it to navigate\na propositional meaning space from Distributional Formal Semantics (DFS).\nMoreover, as Mesh is fully command driven, it is also ideal for teaching\nconnectionistm/PDP: it has for instance been used in a course on\n[Connectionist Language\nProcessing](https://hbrouwer.github.io/courses/clp21/) at [Saarland\nUniversity](https://www.uni-saarland.de/start.html).\n\n# Building and running Mesh\n\nBuilding Mesh should be as straightforward as:\n\n```\n$ cmake .\n$ make\n```\n\nYou can then run Mesh as:\n\n```\n$ ./mesh\nMesh, version 1.0.0: https://github.com/hbrouwer/mesh (`?` for help)\n+ [ OpenMP ]: 10 processor(s) available (10 thread(s) max)\n+ [ OpenMP ]: Dynamic schedule (chunk size: 1)\n```\n\nNote that as Mesh is fully command driven, it is recommended to use\n[rlwrap](https://github.com/hanslub42/rlwrap).\n\n# Usage\n\n```\n$ ./mesh --help\nMesh, version 1.0.0: https://github.com/hbrouwer/mesh (`?` for help)\n+ [ OpenMP ]: 10 processor(s) available (10 thread(s) max)\n+ [ OpenMP ]: Static schedule (chunk size: 0)\n\nUsage: mesh [file | option]\n\n[file]:\nMesh will load and run the specified script file.\n\n[option]:\n`--help`                         Show this help message\n`--version`                      Show version information\n\nWhen no arguments are specified, Mesh will start in CLI mode.\n\n```\n\n# Documentation and Examples\n\nDocumentation is available within Mesh, by typing `?` or `help`, as well as\n[here](docs/welcome.md) in Markdown format. \n\nTutorials are available in the\n[mesh-examples](https://github.com/hbrouwer/mesh-examples) repository, and\ncover networks implementing simple boolean functions, as well as various\npsycholinguistic connectionist models.\n\n# Multithreading\n\nWhen Mesh is compiled with `-DOPENMP=ON` (default), multithreading is\nimplemented through [OpenMP](https://www.openmp.org/), and controlled with\nits [environment\nvariables](https://www.openmp.org/spec-html/5.0/openmpch6.html). For\nexample, the following limits the number of threads to `2`, and enables\n`auto` scheduling:\n\n```\n$ OMP_NUM_THREADS=2 OMP_SCHEDULE=auto ./mesh\nMesh, version 1.0.0: https://github.com/hbrouwer/mesh (`?` for help)\n+ [ OpenMP ]: 10 processor(s) available (2 thread(s) max)\n+ [ OpenMP ]: Auto schedule\n  [:\u003e\n```\n\nNote that in order to use multithreading, you need to activate it in Mesh as\nwell for a given network using `toggleMultithreading` (default: off):\n\n```\n$ OMP_NUM_THREADS=2 mesh plaut.mesh\nMesh, version 1.0.0: https://github.com/hbrouwer/mesh (`?` for help)\n+ [ OpenMP ]: 10 processor(s) available (2 thread(s) max)\n+ [ OpenMP ]: Dynamic schedule (chunk size: 1)\n...\n\u003e Loaded file                    [ plaut.mesh ]\n  [plaut:train\u003e toggleMultithreading\n\u003e Toggled multithreading         [ on ]\n```\n\nYou can inspect the multithreading status of an active network using\n`inspect`:\n\n```\n  [plaut:train\u003e inspect\n| Name:                          plaut\n| Type:                          ffn\n...\n| Multithreading enabled:        true\n| Processor(s) available:        10\n| Maximum #threads:              2\n| Schedule:                      dynamic\n| Chunk size                     1\n```\n\nTo compile Mesh without multithreading, pass the flag `-DOPENMP=OFF` to\nCMake.\n\n**Warning:** If multithreading is enabled, Mesh will always distribute\ncomputations among the available threads. Depending on network size,\nhowever, this may not always lead to improved performance over\nsingle-threaded execution. In fact, the overhead of multithreading may even\ndamage performance. \n\n# Fast exponentiation \n\nMesh implements Nicol N. Schraudolph's fast, compact approximation of the\nexponential function (Schraudolph, 1999). This feature is disabled by\ndefault, but can be enabled by passing the flag `-DFAST_EXP=ON` to CMake. If\nenabled, Mesh will report this on startup:\n\n```\n$ ./mesh\nMesh, version 1.0.0: https://github.com/hbrouwer/mesh (`?` for help)\n+ [ FastExp ]: Using Schraudolph's exp() approximation (c: 60801)\n...\n  [:\u003e\n```\n\n# References\n\nBrouwer, H. (2014). The Electrophysiology of Language Comprehension:\nA Neurocomputational Model. PhD thesis, University of Groningen.\n\nBrouwer, H., Crocker, M. W., Venhuizen, N. J., and Hoeks, J. C. J. (2017).\nA Neurocomputational Model of the N400 and the P600 in Language Processing.\n*Cognitive Science, 41*(S6), 1318-1352.\n\nElman, J. L. (1990). Finding structure in time. *Cognitive Science, 14*(2),\n179-211.\n\nFahlman, S. E. (1988). An empirical study of learning speed in\nback-propagation networks. Technical report CMU-CS-88-162. School of\nComputer Science, Carnegie Mellon University, Pittsburgh, PA 15213.\n\nFrank, S. L., Koppen, M., Noordman, L. G., \u0026 Vonk, W. (2003). Modeling\nknowledge-based inferences in story comprehension. *Cognitive Science,\n27*(6), 875–910. doi:10.1207/s15516709cog2706_3\n\nIgel, C., \u0026 Husken, M. (2000). Improving the Rprop Algorithm. Proceedings of\nthe Second International Symposium on Neural Computation, NC'2000, pp.\n115-121, ICSC, Academic Press, 2000.\n\nJacobs, R. A. (1988). Increased Rates of Convergence Through Learning Rate\nAdapation. *Neural Networks, 1*, 295-307.\n\nNguyen, D. \u0026 Widrow, B. (1990). Improving the learning speed of 2-layer\nneural networks by choosing initial values of adaptive weights. Proceedings\nof the International Joint Conference on Neural Networks (IJCNN), 3:21-26,\nJune 1990.\n\nRohde, D. L. T. (2002). A connectionist model of sentence comprehension and\nproduction. PhD thesis, Carnegie Mellon University.\n\nRumelhart, D. E., Hinton, G. E., \u0026 Williams, R. J. (1986a). Learning\nrepresentations by back-propagating errors. *Nature, 323*, 553-536.\n\nRumelhart, D. E., Hinton, G. E., \u0026 Williams, R. J. (1986b). Learning\ninternal representations by error propagation. In: D. E. Rumelhart \u0026 J. L.\nMcClelland (Eds.), *Parallel distributed processing: Explorations in the\nmicrostructure of cognition, Volume 1: Foundations,* pp. 318-362, Cambridge,\nMA: MIT Press.\n\nSchraudolph, N. N. (1999). A fast, compact approximation of the exponential\nfunction. Neural Computation, 11, 854-862.\n\nVenhuizen, N. J., Hendriks, P., Crocker, M. W., and Brouwer, H. (in press).\nDistributional Formal Semantics. *Information and Computation*. arXiv\npreprint arXiv:2103.01713\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbrouwer%2Fmesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhbrouwer%2Fmesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbrouwer%2Fmesh/lists"}