Giter VIP home page Giter VIP logo

neural-nets-are-weird's Introduction

neural nets are weird

Source code for the article How to trick a neural network into thinking a panda is a vulture. Here's how to get it going! It will download about 1.5GB and take maybe half an hour to set up and compile everything, so don't expect it to be instant. Tested on Linux and OS X.

git clone https://github.com/jvns/neural-nets-are-weird
cd neural-nets-are-weird
make image
make notebook

On Linux: Once you've run those commands, open http://localhost:9990/notebooks/notebooks/neural-nets-are-weird.ipynb?token=weirdness and you should be good to go! This starts an IPython Notebook server, which lets you run code interactively.

On OSX: You must use the address of the VM hosting Docker in the URL (not localhost). This address is shown when starting Docker, or you can get the docker-address by running the command docker-machine ip default Then point your browser to http://docker-address:9990 and follow along with the instructions in the IPython notebook.

There's another Docker image for Caffe here

neural-nets-are-weird's People

Contributors

jvns avatar richb-hanover avatar vidbina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neural-nets-are-weird's Issues

size mismatch problem on ubuntu 14.04

I ran the docker build command
the outputs are as follows:

Get:230 http://http.debian.net/debian/ wheezy/main libraw1394-tools amd64 2.0.9-1 [38.4 kB]
Get:231 http://http.debian.net/debian/ wheezy/main libx11-doc all 2:1.5.0-1+deb7u2 [2609 kB]
Get:232 http://http.debian.net/debian/ wheezy/main manpages-dev all 3.44-1 [1737 kB]
Failed to fetch http://http.debian.net/debian/pool/main/libu/libunistring/libunistring0_0.9.3-5_amd64.deb Size mismatch
Failed to fetch http://http.debian.net/debian/pool/main/x/x11proto-kb/x11proto-kb-dev_1.0.6-2_all.deb Size mismatch
Fetched 113 MB in 6min 19s (299 kB/s)
Unable to correct missing packages.
E: Aborting install.
The command '/bin/sh -c apt-get -y --force-yes install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler' returned a non-zero code: 100


I tried changing the source list of software installation. It didn't work, as the link shown above was still from debian.
I reinstalled ubuntu. I also tried adding --ignore-missing option into dockerfile, which failed as well.

If I may, I want to ask about the possible cause of and solution to this size mismatch problem. Thanks a lot!

docker build fails

Hi
This is my first time doing anything docker related, so sorry if I'm fundamentally misunderstanding something. I'm having trouble with the docker build step. I get the following error message:

`Setting up coreutils (8.21-1ubuntu5) ...
---> d77a8d8bcf95
Removing intermediate container 5e3d8ff83632
Step 12 : RUN cd /opt/caffe && cp Makefile.config.example Makefile.config && echo LS0tIE1ha2VmaWxlLmNvbmZpZy5leGFtcGxlCTIwMTUtMTEtMDcgMTU6NDU6MTIuNTEzNjQ3ODc2IC0wNTAwCisrKyBNYWtlZmlsZS5jb25maWcJMjAxNS0xMS0wOCAyMDozODoyMi4xMDcwNTA2MDggLTA1MDAKQEAgLTUsNyArNSw3IEBACiAjIFVTRV9DVUROTiA6PSAxCiAKICMgQ1BVLW9ubHkgc3dpdGNoICh1bmNvbW1lbnQgdG8gYnVpbGQgd2l0aG91dCBHUFUgc3VwcG9ydCkuCi0jIENQVV9PTkxZIDo9IDEKK0NQVV9PTkxZIDo9IDEKIAogIyB1bmNvbW1lbnQgdG8gZGlzYWJsZSBJTyBkZXBlbmRlbmNpZXMgYW5kIGNvcnJlc3BvbmRpbmcgZGF0YSBsYXllcnMKICMgVVNFX09QRU5DViA6PSAwCk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ERSArPSAkKGRpciAkKHNoZWxsIHB5dGhvbiAtYyAnaW1wb3J0IG51bXB5LmNvcmU7IHByaW50KG51bXB5LmNvcmUuX19maWxlX18pJykpL2luY2x1ZGUK | base64 -d | patch -u Makefile.config

---> Running in 4f153619c8bb

patching file Makefile.config

Hunk #2 FAILED at 65.

1 out of 2 hunks FAILED -- saving rejects to file Makefile.config.rej

The command '/bin/sh -c cd /opt/caffe && cp Makefile.config.example Makefile.config && echo LS0tIE1ha2VmaWxlLmNvbmZpZy5leGFtcGxlCTIwMTUtMTEtMDcgMTU6NDU6MTIuNTEzNjQ3ODc2IC0wNTAwCisrKyBNYWtlZmlsZS5jb25maWcJMjAxNS0xMS0wOCAyMDozODoyMi4xMDcwNTA2MDggLTA1MDAKQEAgLTUsNyArNSw3IEBACiAjIFVTRV9DVUROTiA6PSAxCiAKICMgQ1BVLW9ubHkgc3dpdGNoICh1bmNvbW1lbnQgdG8gYnVpbGQgd2l0aG91dCBHUFUgc3VwcG9ydCkuCi0jIENQVV9PTkxZIDo9IDEKK0NQVV9PTkxZIDo9IDEKIAogIyB1bmNvbW1lbnQgdG8gZGlzYWJsZSBJTyBkZXBlbmRlbmNpZXMgYW5kIGNvcnJlc3BvbmRpbmcgZGF0YSBsYXllcnMKICMgVVNFX09QRU5DViA6PSAwCkBAIC02NSwxNCArNjUsMTQgQEAKIAkJL3Vzci9saWIvcHl0aG9uMi43L2Rpc3QtcGFja2FnZXMvbnVtcHkvY29yZS9pbmNsdWRlCiAjIEFuYWNvbmRhIFB5dGhvbiBkaXN0cmlidXRpb24gaXMgcXVpdGUgcG9wdWxhci4gSW5jbHVkZSBwYXRoOgogIyBWZXJpZnkgYW5hY29uZGEgbG9jYXRpb24sIHNvbWV0aW1lcyBpdCdzIGluIHJvb3QuCi0jIEFOQUNPTkRBX0hPTUUgOj0gJChIT01FKS9hbmFjb25kYQotIyBQWVRIT05fSU5DTFVERSA6PSAkKEFOQUNPTkRBX0hPTUUpL2luY2x1ZGUgXAotCQkjICQoQU5BQ09OREFfSE9NRSkvaW5jbHVkZS9weXRob24yLjcgXAotCQkjICQoQU5BQ09OREFfSE9NRSkvbGliL3B5dGhvbjIuNy9zaXRlLXBhY2thZ2VzL251bXB5L2NvcmUvaW5jbHVkZSBcCitBTkFDT05EQV9IT01FIDo9IC9vcHQvY29uZGEKK1BZVEhPTl9JTkNMVURFIDo9ICQoQU5BQ09OREFfSE9NRSkvaW5jbHVkZSBcCisJCSAkKEFOQUNPTkRBX0hPTUUpL2luY2x1ZGUvcHl0aG9uMi43IFwKKwkJICQoQU5BQ09OREFfSE9NRSkvbGliL3B5dGhvbjIuNy9zaXRlLXBhY2thZ2VzL251bXB5L2NvcmUvaW5jbHVkZSBcCiAKICMgV2UgbmVlZCB0byBiZSBhYmxlIHRvIGZpbmQgbGlicHl0aG9uWC5YLnNvIG9yIC5keWxpYi4KIFBZVEhPTl9MSUIgOj0gL3Vzci9saWIKLSMgUFlUSE9OX0xJQiA6PSAkKEFOQUNPTkRBX0hPTUUpL2xpYgorUFlUSE9OX0xJQiA6PSAkKEFOQUNPTkRBX0hPTUUpL2xpYgogCiAjIEhvbWVicmV3IGluc3RhbGxzIG51bXB5IGluIGEgbm9uIHN0YW5kYXJkIHBhdGggKGtlZyBvbmx5KQogIyBQWVRIT05fSU5DTFVERSArPSAkKGRpciAkKHNoZWxsIHB5dGhvbiAtYyAnaW1wb3J0IG51bXB5LmNvcmU7IHByaW50KG51bXB5LmNvcmUuX19maWxlX18pJykpL2luY2x1ZGUK | base64 -d | patch -u Makefile.config' returned a non-zero code: 1`

My machine is a Windows machine and I tried it two ways:

  1. installing docker toolbox and running it that way
  2. installing docker inside an ubuntu vagrant box and running it that way

I'm not sure what the problem is as I can't make any sense of the error codes (and this is a pretty hard thing to google). Thanks for any help!!

The end of the notebook is not working

Hi (again),

I don't know what is actually failing but if you compute from top to bottom it starts to fail from the step :

Step 1: the black screen

(See my other issue related to that point)

Then you have an output obviously not functioning.

capture1

capture2

After that step the whole process is failing ... I let you have a look to this.

Thanks again for your awesome work.

Jonathan DEKHTIAR

Failed to fetch http://........ Size mismatch

Get:231 http://http.debian.net/debian/ wheezy/main libsnappy-dev amd64 1.0.5-2 [38.0 kB]

Failed to fetch http://http.debian.net/debian/pool/main/libu/libunistring/libunistring0_0.9.3-5_amd64.deb Size mismatch
Failed to fetch http://http.debian.net/debian/pool/main/x/x11proto-kb/x11proto-kb-dev_1.0.6-2_all.deb Size mismatch
Failed to fetch http://http.debian.net/debian/pool/main/o/opencv/libopencv-objdetect2.3_2.3.1-11+deb7u1_amd64.deb Error reading from server. Remote end closed connection [IP: 5.153.231.35 80]
Fetched 113 MB in 7min 51s (240 kB/s)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get -y --force-yes install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler' returned a non-zero code: 100

Var not defined in one cell

Hi,

I tried to fix this bug, but didn't find it ;)

Cell containing :

Step 1: the black screen

black = np.zeros_like(grad)
_ = predict(black, n_preds=5)

The var "grad" is not defined, I see how you compute it (with the function below), but what you use in input of the function ?

Please fix the notebook ;)

Thanks a lot for your awesome work.

License

Hi.
Thank you for the Dockerfile and the Python notebook. It's super helpful and I've been doing some research based on it. How is the repo licensed? I wonder if it's OK to fork and modify your code, while declaring my part as MIT.

Wrong address/wrong port in documentation

The instructions displayed by the neural-nets-fun:caffe container give the wrong address and port on some OS's.

On Linux use port 9990 - http://0.0.0.0:9990 in your browser (tested on Ubuntu 14.04.3)

On OSX use the docker-machine address and port 9990 - http://docker-machine:9990 where docker-address is the IP address displayed by the docker startup script (e.g. 192.168.99.100 in the "screen shot" below). (Tested on OSX 10.10.5)

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100

OptionError: "No such keys(s): 'display.mpl_style'" in notebook

---------------------------------------------------------------------------
OptionError                               Traceback (most recent call last)
<ipython-input-2-0c739e39c1c5> in <module>()
      9 import pandas as pd
     10 get_ipython().magic(u'matplotlib inline')
---> 11 pd.set_option('display.mpl_style', 'default')
     12 caffe_root = '/opt/caffe/'
     13 

/opt/conda/lib/python2.7/site-packages/pandas/core/config.pyc in __call__(self, *args, **kwds)
    225 
    226     def __call__(self, *args, **kwds):
--> 227         return self.__func__(*args, **kwds)
    228 
    229     @property

/opt/conda/lib/python2.7/site-packages/pandas/core/config.pyc in _set_option(*args, **kwargs)
    117 
    118     for k, v in zip(args[::2], args[1::2]):
--> 119         key = _get_single_key(k, silent)
    120 
    121         o = _get_registered_option(key)

/opt/conda/lib/python2.7/site-packages/pandas/core/config.pyc in _get_single_key(pat, silent)
     81         if not silent:
     82             _warn_if_deprecated(pat)
---> 83         raise OptionError('No such keys(s): {pat!r}'.format(pat=pat))
     84     if len(keys) > 1:
     85         raise OptionError('Pattern matched multiple keys')

OptionError: "No such keys(s): 'display.mpl_style'"

๐Ÿ‘‹ looks like something change in a version somewhere between version 2.7.10 and 2.7.15. display.mpl_style became deprecated.

Some image urls are broken too, but that's ok. Next time, I suggest downloading pictures locally for this to keep working. Anyway, not a big problem. Amazing work in here and very interesting reading! ๐Ÿ‘

installation failed at the step of libboost-all-dev

Hello,
When I run on my ubuntu 16.04 using the command "docker build -t neural-nets-fun:caffe ."
I met this problem,

Step 7 : RUN apt-get -y --force-yes install --no-install-recommends libboost-all-dev
---> Running in 652e192f2cc1
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libboost-all-dev : Depends: libboost-iostreams-dev but it is not going to be installed
Depends: libboost-mpi-dev but it is not going to be installed
Depends: libboost-mpi-python-dev but it is not going to be installed
Depends: libboost-regex-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-get -y --force-yes install --no-install-recommends libboost-all-dev' returned a non-zero code: 100

any idea?
best,

Why computing gradients?

Thanks for your contribution! And it helps me a lot to understand the special characteristic of CNN!
But I don't know why you compute gradients of a black image in order to make it more likely to a specific class.

docker's clone command fails with make: *** [image] Error 128 (Could not parse object 'cc521a0801143c242f5da0e95737070c02ce15ab')

As shown here:
https://travis-ci.com/GabLeRoux/neural-nets-are-weird/jobs/150002859

Cloning into '/opt/caffe'...
fatal: Could not parse object 'cc521a0801143c242f5da0e95737070c02ce15ab'.
The command '/bin/sh -c git clone --depth 1 https://github.com/BVLC/caffe.git /opt/caffe && cd /opt/caffe && git reset --hard $CAFFE_REVISION && patch -p1 < /tmp/caffe.patch && cp Makefile.config.example Makefile.config && make all -j8 && make pycaffe -j8' returned a non-zero code: 128
make: *** [image] Error 128

Solution would be to clone without --depth 1.

Trouble running on OSX 10.10

UPDATE: Solved - See: #1 (comment)

Thanks for taking the time to post this container/tutorial.

I'm using OSX 10.10.5, and can (seemingly) install Docker from docker.com successfully. That is, I can run the "hello world" container and get the expected output.

I then run the docker build command as shown on your main page, and the caffe container seems to build and be ready.

I have trouble with the next step. I see the following in Terminal:

bash-3.2$ docker run -i -p 9990:8888 -v $PWD:/neural-nets -t neural-nets-fun:caffe /bin/bash -c 'export     PYTHONPATH=/opt/caffe/python && cd /neural-nets && ipython notebook --no-browser --ip 0.0.0.0'
[I 03:31:48.502 NotebookApp] Writing notebook server cookie secret to /.local/share/jupyter/runtime/notebook_cookie_secret
[I 03:31:48.560 NotebookApp] Serving notebooks from local directory: /neural-nets
[I 03:31:48.560 NotebookApp] 0 active kernels
[I 03:31:48.561 NotebookApp] The IPython Notebook is running at: http://0.0.0.0:8888/
[I 03:31:48.561 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

However, when I go to my web browser to connect to http://0.0.0.0:8888/ or localhost:8888, I can't connect, and see ERR_CONNECTION_REFUSED in Chrome. Further debugging:

  • netstat does not show that either port 9990 or 8888 are open
  • changing the invocation to use "localhost" instead of "0.0.0.0" doesn't help
  • the terminal shows "0 active kernels" - does this mean anything?
  • running the following command docker run -i -p 9990:8888 -v $PWD:/neural-nets -t neural-nets-fun:caffe gives me a root shell in the terminal.

Any ideas what could be wrong/what I can do to get on the air? Thanks!

single-channel models

how can we actually change the image shapes if a model is trained for single-channel (images) grayscale?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.