Code samples for my book "Neural Networks and Deep Learning"

Overview

Code samples for "Neural Networks and Deep Learning"

This repository contains code samples for my book on "Neural Networks and Deep Learning".

The code is written for Python 2.6 or 2.7. Michal Daniel Dobrzanski has a repository for Python 3 here. I will not be updating the current repository for Python 3 compatibility.

The program src/network3.py uses version 0.6 or 0.7 of the Theano library. It needs modification for compatibility with later versions of the library. I will not be making such modifications.

As the code is written to accompany the book, I don't intend to add new features. However, bug reports are welcome, and you should feel free to fork and modify the code.

License

MIT License

Copyright (c) 2012-2018 Michael Nielsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Adding a more polished Network class.

    Adding a more polished Network class.

    Network.py provides a more polished version of the Network class from backprop2.py. Improvements are:

    • Better documentation.
    • Saving and loading.
    • List-like operators (splicing, concatonating).

    (The list-like operators are convenient for pretraining work.)

    This is intended for an experimental branch, but github won't let me propose a pull request to a non-existant branch.

    opened by colah 4
  • removed numpy.vectorize() wrappers

    removed numpy.vectorize() wrappers

    As they slow down the sigmoid functions considerably and unnecessarily. The network's SGD method runs several times faster with this simple modification.

    opened by CesiumLifeJacket 3
  • Added recommended Git Attributes file

    Added recommended Git Attributes file

    I added the Git Attributes which will normalize all line enddings in the binary of all text files. (The enddings are different for linux, windows, mac, etc.) It's kinda sorta pointless, but it's a nice perk Git offers, so why not have it? It also provides a bunch of other things not really needed for this repo.

    I also added basic operating system junk files to the gitignore (because they were going to be committed)

    opened by Tommsy64 3
  • align funciton with latest theano version 0.8 or above

    align funciton with latest theano version 0.8 or above

    with theano upgrade to 0.8 or above,the function downsample.max_pool_2d() has been removed. Should replace with pool.pool_2d.Otherwise, it will crash.

    opened by jowettcz 2
  • Remove unused vector/matrix creation

    Remove unused vector/matrix creation

    nabla_b and nabla_w are lists which store gradient, but their initial values are not used. So it isn't needed to call np.zero to create vector/matrix.

    opened by tyfkda 2
  • Numpy's exp() is already vectorized, remove redundant vectorize() call.

    Numpy's exp() is already vectorized, remove redundant vectorize() call.

    No intended behavior change. The vectorize() documentation points out that vectorize() is not fast, and indeed after this change the time to train one epoch is reduced from ~37.6s to ~10.5s on my laptop -- a 72% reduction.

    I haven't read more than Chapter 1 yet (in fact, I haven't completed Chapter 1), so maybe something like this can be done in other places too.

    opened by nico 2
  • Use np.add instead of iterating over list

    Use np.add instead of iterating over list

    Hi thanks for this great learning resource, I think your writing is amazing.

    I'm a complete newbie in python but I think this PR makes this bit of code less verbose.

    I know it's not a big change but still... There might be a good reason this wasn't done in the first place, in which case please disregard this PR.

    opened by feresr 1
  • Theano 0.9

    Theano 0.9

    These are the basic modifications needed for network3.py to be compatible with the latest Theano 0.9.0 (which pip will automatically install right now). Possibly a mention should also be added to the README about Theano moving towards a new GPU backend (more details at http://deeplearning.net/software/theano/tutorial/using_gpu.html).

    opened by aedancullen 1
  • Outdated code updates

    Outdated code updates

    I've update some of the code that uses deprecated theano functions

    • Replaced theano.tensor.signal.downsample.max_pool_2d function with the newer theano.tensor.signal.pool.pool_2d function (Python throws a warning when using the earlier one)
    • Replaced the deprecated theano.tensor.nnet.conv.conv2d with the newer Theano.tensor.nnet.conv2d function. Also, replaced the deprecated image_shape parameter with input_shape .

    Also, removed the redundant cost_ij variable in network3.py.

    opened by ayooshkathuria 1
  • change about function max_pool_2d()

    change about function max_pool_2d()

    "downsample module has been moved to the theano.tensor.signal.pool module." so i modify the theano.tensor.signal.downsample.max_pool_2d() to theano.tensor.signal.pool.pool_2d()

    opened by Victorianuonuo 1
  • python-izes classes

    python-izes classes

    While reading the code base, I noticed that you had lots of class declarations of the forms

    class Foo():
        ....
    
    class Foo:
        ....
    

    My sense is that you're not planning on making any classes to be extensible via inheritance, but the more Pythonic way of doing this is to inherit the base object:

    class Foo(object):
    

    This permits inheritance, which the old-style classes (eg, class Foo:) preclude.

    In the process, my editor, which aggressively trims trailing whitespace, discovered lots of this in your source files -- hence the larger-than-expected diff. I'm happy amend this commit to include only the class declaration changes and leave the whitespace alone if you're particular about these things. Lemme know.

    opened by drjerry 1
  • If anyone wanted a compatibility with the latest python versions, I made a fork

    If anyone wanted a compatibility with the latest python versions, I made a fork

    This isn't meant to be a PR, so sorry for making one, but I didn't find another way to notify anyone who might be interested. As you may know, the current repository is made to work with python 2.7, which is old and incompatible. I tried searching for one which was compatible with the latest version but no luck(Michal Daniel Dobrzanski isn't the one I was looking for), so I decided to make one: https://github.com/unexploredtest/neural-networks-and-deep-learning Hopefully somebody will find it useful.

    opened by unexploredtest 0
  • Update network.py

    Update network.py

    I am working on your online book and projects using Python 3.5. Since I used a different and newer python version, I came across several problems and solved them by making some changes in network.py and mnist_loader files. Now the code is compatible with Python 3.5 The biggest problem is zip variables haven't len() attribute in 3.5. So I converted training_data, test_data to the list variables. I had to make a deep copy of original training and test data because when they are converted to list variables, they can't be reused.

    opened by YCAyca 4
  • Update mnist_loader.py

    Update mnist_loader.py

    I am working on your online book and projects using Python 3.5. Since I used a different and newer python version, I came across several problems and solved them by making some changes in network.py and mnist_loader files. Now the code is compatible with Python 3.5 I added just "import _pickle as cPickle" line because in 3.5 cPickle isn't defined and it should be used in standard library version.

    opened by YCAyca 1
Owner
Michael Nielsen
Searching for the numinous
Michael Nielsen
Sample code from the Neural Networks from Scratch book.

Neural Networks from Scratch (NNFS) book code Code from the NNFS book (https://nnfs.io) separated by chapter.

Harrison 172 Dec 31, 2022
Like Dirt-Samples, but cleaned up

Clean-Samples Like Dirt-Samples, but cleaned up, with clear provenance and license info (generally a permissive creative commons licence but check the

TidalCycles 39 Nov 30, 2022
PAWS 🐾 Predicting View-Assignments with Support Samples

This repo provides a PyTorch implementation of PAWS (predicting view assignments with support samples), as described in the paper Semi-Supervised Learning of Visual Features by Non-Parametrically Predicting View Assignments with Support Samples.

Facebook Research 437 Dec 23, 2022
Learn about Spice.ai with in-depth samples

Samples Learn about Spice.ai with in-depth samples ServerOps - Learn when to run server maintainance during periods of low load Gardener - Intelligent

Spice.ai 16 Mar 23, 2022
Training Confidence-Calibrated Classifier for Detecting Out-of-Distribution Samples / ICLR 2018

Training Confidence-Calibrated Classifier for Detecting Out-of-Distribution Samples This project is for the paper "Training Confidence-Calibrated Clas

null 168 Nov 29, 2022
Repo for FUZE project. I will also publish some Linux kernel LPE exploits for various real world kernel vulnerabilities here. the samples are uploaded for education purposes for red and blue teams.

Linux_kernel_exploits Some Linux kernel exploits for various real world kernel vulnerabilities here. More exploits are yet to come. This repo contains

Wei Wu 472 Dec 21, 2022
NeurIPS 2021, "Fine Samples for Learning with Noisy Labels"

[Official] FINE Samples for Learning with Noisy Labels This repository is the official implementation of "FINE Samples for Learning with Noisy Labels"

mythbuster 27 Dec 23, 2022
Qimera: Data-free Quantization with Synthetic Boundary Supporting Samples

Qimera: Data-free Quantization with Synthetic Boundary Supporting Samples This repository is the official implementation of paper [Qimera: Data-free Q

Kanghyun Choi 21 Nov 3, 2022
The Malware Open-source Threat Intelligence Family dataset contains 3,095 disarmed PE malware samples from 454 families

MOTIF Dataset The Malware Open-source Threat Intelligence Family (MOTIF) dataset contains 3,095 disarmed PE malware samples from 454 families, labeled

Booz Allen Hamilton 112 Dec 13, 2022
Final project for machine learning (CSC 590). Detection of hepatitis C and progression through blood samples.

Hepatitis C Blood Based Detection Final project for machine learning (CSC 590). Dataset from Kaggle. Using data from previous hepatitis C blood panels

Jennefer Maldonado 1 Dec 28, 2021
Analysis of Antarctica sequencing samples contaminated with SARS-CoV-2

Analysis of SARS-CoV-2 reads in sequencing of 2018-2019 Antarctica samples in PRJNA692319 The samples analyzed here are described in this preprint, wh

Jesse Bloom 4 Feb 9, 2022
Experimental solutions to selected exercises from the book [Advances in Financial Machine Learning by Marcos Lopez De Prado]

Advances in Financial Machine Learning Exercises Experimental solutions to selected exercises from the book Advances in Financial Machine Learning by

Brian 1.4k Jan 4, 2023
Repository for scripts and notebooks from the book: Programming PyTorch for Deep Learning

Repository for scripts and notebooks from the book: Programming PyTorch for Deep Learning

Ian Pointer 368 Dec 17, 2022
Official repository of my book: "Deep Learning with PyTorch Step-by-Step: A Beginner's Guide"

This is the official repository of my book "Deep Learning with PyTorch Step-by-Step". Here you will find one Jupyter notebook for every chapter in the book.

Daniel Voigt Godoy 340 Jan 1, 2023
Free Book about Deep-Learning approaches for Chess (like AlphaZero, Leela Chess Zero and Stockfish NNUE)

Free Book about Deep-Learning approaches for Chess (like AlphaZero, Leela Chess Zero and Stockfish NNUE)

Dominik Klein 189 Dec 21, 2022
MATLAB codes of the book "Digital Image Processing Fourth Edition" converted to Python

Digital Image Processing Python MATLAB codes of the book "Digital Image Processing Fourth Edition" converted to Python TO-DO: Refactor scripts, curren

Merve Noyan 24 Oct 16, 2022
Python Algorithm Interview Book Review

파이썬 μ•Œκ³ λ¦¬μ¦˜ 인터뷰 μ±… 리뷰 리뷰 IT λŒ€κΈ°μ—…μ— λ“€μ–΄κ°€κ³  싢은 λͺ©ν‘œκ°€ μžˆλ‹€. λ‚΄κ°€ κΏˆκΏ”μ˜¨ νšŒμ‚¬μ—μ„œ μΌν•˜λŠ” μ‚¬λžŒλ“€μ˜ λͺ¨μŠ΅μ„ 보면 λ©‹μžˆλ‹€κ³  생각이 λ“€κ³  λ‚˜μ˜ λͺ©ν‘œμ— λŒ€ν•œ 열망이 κ°•ν•΄μ§€λŠ” 것 κ°™λ‹€. 미래의 핡심 사업 쀑 ν•˜λ‚˜μΈ SW 뢀뢄을 이끌고 λ°œμ „μ‹œν‚€λŠ” μš°λ¦¬λ‚˜λΌμ˜ I

SharkBSJ 1 Dec 14, 2021
This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

Gautam Singh 66 Dec 26, 2022
TensorFlow code for the neural network presented in the paper: "Structural Language Models of Code" (ICML'2020)

SLM: Structural Language Models of Code This is an official implementation of the model described in: "Structural Language Models of Code" [PDF] To ap

null 73 Nov 6, 2022