{"id":19863783,"url":"https://github.com/sandialabs/whetstone","last_synced_at":"2025-05-02T04:31:25.060Z","repository":{"id":45084294,"uuid":"142175535","full_name":"sandialabs/Whetstone","owner":"sandialabs","description":null,"archived":false,"fork":false,"pushed_at":"2018-10-03T23:44:00.000Z","size":279,"stargazers_count":49,"open_issues_count":1,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-06T22:42:35.824Z","etag":null,"topics":["neuromorphic","neuromorphic-computing","scr-2331","spiking-neural-networks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandialabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-24T15:08:08.000Z","updated_at":"2025-03-29T18:57:56.000Z","dependencies_parsed_at":"2022-07-13T06:00:37.694Z","dependency_job_id":null,"html_url":"https://github.com/sandialabs/Whetstone","commit_stats":null,"previous_names":["snl-nerl/whetstone"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FWhetstone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FWhetstone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FWhetstone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FWhetstone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandialabs","download_url":"https://codeload.github.com/sandialabs/Whetstone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251986821,"owners_count":21675952,"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":["neuromorphic","neuromorphic-computing","scr-2331","spiking-neural-networks"],"created_at":"2024-11-12T15:16:04.823Z","updated_at":"2025-05-02T04:31:20.052Z","avatar_url":"https://github.com/sandialabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Copyright 2018 National Technology \u0026 Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.\r\n\r\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3 of the License only. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. Tf not, see https://www.gnu.org/licenses.\r\n    \r\nWhetstone\r\n=========\r\n\r\nThis package provides a framework for training deep spiking neural networks using keras.\r\nWhetstone is designed to be extendable, modular, and easy-to-use.\r\n\r\n--------\r\nSetup\r\n--------\r\nBefore an initial release, you must clone the git repo and install the package manually.\r\n\r\nThe easiest way to this is:\r\n1. Find a location where you have write permissions and would like a copy of the Whetstone package.\r\n2. `git clone --branch master\r\nhttps://github.com/SNL-NERL/Whetstone.git`\r\nThis will create a new sub-directory called Whetstone which will contain all the relevant code.\r\n3. In the new directory, run `pip install .` to install the package.\r\n\r\nTypical install requires less than 1 minute.\r\n\r\n-------\r\nRequirements\r\n-------\r\nWhetstone has been tested on Ubuntu Linux 14.04 and 16.04 and is written using Python.\r\n\r\nTesting was performed using Python 2.7.6, though the code should be generally compatible with Python 3.\r\n\r\nA CUDA-capable GPU is not required by highly recommended for larger network models.  Testing was performed using NVIDIA Titan Xp and NVIDIA V100 GPUs.\r\n\r\nAverage runtime varies wildly depending on system setup, dataset, and network complexity.  The example listed below will take approximately 1 minute using a Titan Xp GPU.\r\n\r\n-------\r\nDependencies\r\n-------\r\n\r\n- Keras 2.1.2\r\n- Tensorflow 1.3.0\r\n- Numpy 1.14.5\r\n\r\nNote:  Generally, the version numbers do not need to be exactly those listed.  However, care should be taken particularly with newer versions of Keras due to changes in default parameter values.\r\nE.g. K.epsilon()\r\n\r\nSome example scripts require\r\n- opencv-python 3.4.1.15\r\n- Keras-rl 0.4.2\r\n\r\n-------\r\nDocumentation\r\n-------\r\nDocumentation is available at [docs](/docs/index.md).\r\n\r\n------\r\nExample\r\n------\r\nThe code below can be used to train a simple densely connected spiking network for classifying mnist.\r\n\r\nThis and additional examples, as well as benchmarking/logging scripts, can be found in the examples directory.\r\n\r\n```\r\n\r\nfrom __future__ import print_function\r\n\"\"\"\r\nLight-weight demo of SimpleSharpener, Spiking_BRelu, and Softmax_Decode for a fully connected net on mnist.\r\n\"\"\"\r\n\r\nimport os\r\nimport numpy as np\r\nimport keras\r\nfrom keras.datasets import mnist\r\nfrom keras.models import Sequential\r\nfrom keras.utils import to_categorical\r\nfrom keras.layers import Dense\r\nfrom keras.optimizers import Adadelta\r\nfrom whetstone.layers import Spiking_BRelu, Softmax_Decode, key_generator\r\nfrom whetstone.callbacks import SimpleSharpener, WhetstoneLogger\r\n\r\nnumClasses = 10\r\n(x_train, y_train),(x_test, y_test) = mnist.load_data()\r\n\r\nx_train = x_train.astype('float32')\r\nx_test = x_test.astype('float32')\r\nx_train /= 255\r\nx_test /= 255\r\n\r\ny_train = to_categorical(y_train, numClasses)\r\ny_test = to_categorical(y_test, numClasses)\r\n\r\nx_train = np.reshape(x_train, (60000,28*28))\r\nx_test = np.reshape(x_test, (10000,28*28))\r\n\r\nkey = key_generator(num_classes=10, width=100)\r\n\r\nmodel = Sequential()\r\nmodel.add(Dense(256, input_shape=(28*28,)))\r\nmodel.add(Spiking_BRelu())\r\nmodel.add(Dense(64))\r\nmodel.add(Spiking_BRelu())\r\nmodel.add(Dense(100))\r\nmodel.add(Spiking_BRelu())\r\nmodel.add(Softmax_Decode(key))\r\n\r\nsimple = SimpleSharpener(start_epoch=5, steps=5, epochs=True, bottom_up=True)\r\n\r\n# Create a new directory to save the logs in.\r\nlog_dir = './simple_logs'\r\nif not os.path.exists(log_dir):\r\n    os.makedirs(log_dir)\r\n\r\nlogger = WhetstoneLogger(logdir=log_dir, sharpener=simple)\r\n\r\nmodel.compile(loss='categorical_crossentropy', optimizer=Adadelta(lr=4.0, rho=0.95, epsilon=1e-8, decay=0.0), metrics=['accuracy'])\r\nmodel.fit(x_train, y_train, batch_size=128, epochs=21, callbacks=[simple, logger])\r\n\r\nprint(model.evaluate(x_test, y_test))\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandialabs%2Fwhetstone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandialabs%2Fwhetstone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandialabs%2Fwhetstone/lists"}