{"id":13419006,"url":"https://github.com/karpathy/convnetjs","last_synced_at":"2025-05-13T19:13:42.824Z","repository":{"id":12963828,"uuid":"15642233","full_name":"karpathy/convnetjs","owner":"karpathy","description":"Deep Learning in Javascript. Train Convolutional Neural Networks (or ordinary ones) in your browser.","archived":false,"fork":false,"pushed_at":"2023-01-07T21:33:23.000Z","size":27806,"stargazers_count":10976,"open_issues_count":76,"forks_count":2044,"subscribers_count":593,"default_branch":"master","last_synced_at":"2025-05-09T07:06:30.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karpathy.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-05T00:12:15.000Z","updated_at":"2025-05-08T13:12:58.000Z","dependencies_parsed_at":"2023-01-13T17:13:44.587Z","dependency_job_id":null,"html_url":"https://github.com/karpathy/convnetjs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karpathy%2Fconvnetjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karpathy%2Fconvnetjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karpathy%2Fconvnetjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karpathy%2Fconvnetjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karpathy","download_url":"https://codeload.github.com/karpathy/convnetjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010813,"owners_count":21998995,"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":[],"created_at":"2024-07-30T22:01:10.046Z","updated_at":"2025-05-13T19:13:42.792Z","avatar_url":"https://github.com/karpathy.png","language":"JavaScript","readme":"\n# ConvNetJS\n\nConvNetJS is a Javascript implementation of Neural networks, together with nice browser-based demos. It currently supports:\n\n- Common **Neural Network modules** (fully connected layers, non-linearities)\n- Classification (SVM/Softmax) and Regression (L2) **cost functions**\n- Ability to specify and train **Convolutional Networks** that process images\n- An experimental **Reinforcement Learning** module, based on Deep Q Learning\n\nFor much more information, see the main page at [convnetjs.com](http://convnetjs.com)\n\n**Note**: I am not actively maintaining ConvNetJS anymore because I simply don't have time. I think the npm repo might not work at this point.\n\n## Online Demos\n- [Convolutional Neural Network on MNIST digits](http://cs.stanford.edu/~karpathy/convnetjs/demo/mnist.html)\n- [Convolutional Neural Network on CIFAR-10](http://cs.stanford.edu/~karpathy/convnetjs/demo/cifar10.html)\n- [Toy 2D data](http://cs.stanford.edu/~karpathy/convnetjs/demo/classify2d.html)\n- [Toy 1D regression](http://cs.stanford.edu/~karpathy/convnetjs/demo/regression.html)\n- [Training an Autoencoder on MNIST digits](http://cs.stanford.edu/~karpathy/convnetjs/demo/autoencoder.html)\n- [Deep Q Learning Reinforcement Learning demo](http://cs.stanford.edu/people/karpathy/convnetjs/demo/rldemo.html)\n- [Image Regression (\"Painting\")](http://cs.stanford.edu/~karpathy/convnetjs/demo/image_regression.html)\n- [Comparison of SGD/Adagrad/Adadelta on MNIST](http://cs.stanford.edu/people/karpathy/convnetjs/demo/trainers.html)\n\n## Example Code\n\nHere's a minimum example of defining a **2-layer neural network** and training\nit on a single data point:\n\n```javascript\n// species a 2-layer neural network with one hidden layer of 20 neurons\nvar layer_defs = [];\n// input layer declares size of input. here: 2-D data\n// ConvNetJS works on 3-Dimensional volumes (sx, sy, depth), but if you're not dealing with images\n// then the first two dimensions (sx, sy) will always be kept at size 1\nlayer_defs.push({type:'input', out_sx:1, out_sy:1, out_depth:2});\n// declare 20 neurons, followed by ReLU (rectified linear unit non-linearity)\nlayer_defs.push({type:'fc', num_neurons:20, activation:'relu'}); \n// declare the linear classifier on top of the previous hidden layer\nlayer_defs.push({type:'softmax', num_classes:10});\n\nvar net = new convnetjs.Net();\nnet.makeLayers(layer_defs);\n\n// forward a random data point through the network\nvar x = new convnetjs.Vol([0.3, -0.5]);\nvar prob = net.forward(x); \n\n// prob is a Vol. Vols have a field .w that stores the raw data, and .dw that stores gradients\nconsole.log('probability that x is class 0: ' + prob.w[0]); // prints 0.50101\n\nvar trainer = new convnetjs.SGDTrainer(net, {learning_rate:0.01, l2_decay:0.001});\ntrainer.train(x, 0); // train the network, specifying that x is class zero\n\nvar prob2 = net.forward(x);\nconsole.log('probability that x is class 0: ' + prob2.w[0]);\n// now prints 0.50374, slightly higher than previous 0.50101: the networks\n// weights have been adjusted by the Trainer to give a higher probability to\n// the class we trained the network with (zero)\n```\n\nand here is a small **Convolutional Neural Network** if you wish to predict on images:\n\n```javascript\nvar layer_defs = [];\nlayer_defs.push({type:'input', out_sx:32, out_sy:32, out_depth:3}); // declare size of input\n// output Vol is of size 32x32x3 here\nlayer_defs.push({type:'conv', sx:5, filters:16, stride:1, pad:2, activation:'relu'});\n// the layer will perform convolution with 16 kernels, each of size 5x5.\n// the input will be padded with 2 pixels on all sides to make the output Vol of the same size\n// output Vol will thus be 32x32x16 at this point\nlayer_defs.push({type:'pool', sx:2, stride:2});\n// output Vol is of size 16x16x16 here\nlayer_defs.push({type:'conv', sx:5, filters:20, stride:1, pad:2, activation:'relu'});\n// output Vol is of size 16x16x20 here\nlayer_defs.push({type:'pool', sx:2, stride:2});\n// output Vol is of size 8x8x20 here\nlayer_defs.push({type:'conv', sx:5, filters:20, stride:1, pad:2, activation:'relu'});\n// output Vol is of size 8x8x20 here\nlayer_defs.push({type:'pool', sx:2, stride:2});\n// output Vol is of size 4x4x20 here\nlayer_defs.push({type:'softmax', num_classes:10});\n// output Vol is of size 1x1x10 here\n\nnet = new convnetjs.Net();\nnet.makeLayers(layer_defs);\n\n// helpful utility for converting images into Vols is included\nvar x = convnetjs.img_to_vol(document.getElementById('some_image'))\nvar output_probabilities_vol = net.forward(x)\n```\n\n## Getting Started\nA [Getting Started](http://cs.stanford.edu/people/karpathy/convnetjs/started.html) tutorial is available on main page.\n\nThe full [Documentation](http://cs.stanford.edu/people/karpathy/convnetjs/docs.html) can also be found there.\n\nSee the **releases** page for this project to get the minified, compiled library, and a direct link to is also available below for convenience (but please host your own copy)\n\n- [convnet.js](http://cs.stanford.edu/people/karpathy/convnetjs/build/convnet.js)\n- [convnet-min.js](http://cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js)\n\n## Compiling the library from src/ to build/\nIf you would like to add features to the library, you will have to change the code in `src/` and then compile the library into the `build/` directory. The compilation script simply concatenates files in `src/` and then minifies the result.\n\nThe compilation is done using an ant task: it compiles `build/convnet.js` by concatenating the source files in `src/` and then minifies the result into `build/convnet-min.js`. Make sure you have **ant** installed (on Ubuntu you can simply *sudo apt-get install* it), then cd into `compile/` directory and run:\n\n    $ ant -lib yuicompressor-2.4.8.jar -f build.xml\n\nThe output files will be in `build/`\n## Use in Node\nThe library is also available on *node.js*:\n\n1. Install it: `$ npm install convnetjs`\n2. Use it: `var convnetjs = require(\"convnetjs\");`\n\n## License\nMIT\n","funding_links":[],"categories":["JavaScript","Researchers","AI Framework","6. 其他","Machine Learning","Project/Product","Machine Learning [🔝](#readme)","Table of Contents","Deep Learning","Uncategorized","机器学习","Frameworks","Images"],"sub_categories":["Frameworks","Quant","6.1 AI","Runner","React Components","Uncategorized","运行器","List of lists","运行器e2e测试"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpathy%2Fconvnetjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarpathy%2Fconvnetjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpathy%2Fconvnetjs/lists"}