Group Group Group Group Group Group Group Group Group Forums

Beginning Machine Learning with Keras & Core ML

In this Keras machine learning tutorial, you’ll learn how to train a convolutional neural network model, convert it to Core ML, and integrate it into an iOS app.

This is a companion discussion topic for the original entry at

So, executing docker run command for the ML learning tutorial (audrey’s) tells me that keras-mnist doesn’t exist:
_docker run --rm -it -p 8888:8888 -v $(pwd)/notebook:/workspace/notebook keras-mnist
Unable to find image ‘keras-mnist:latest’ locally
docker: Error response from daemon: pull access denied for keras-mnist, repository does not exist or may require ‘docker login’.

What is the magic? (renamed?).


Ahhhh; it’s a typo. Turns out the built image is called keras-mninst, not keras-mnist. My bad! Thanks, though.

jps (see, below):
A122758:docker-keras wz3264$ docker run -it -p 8888:8888 -v $(pwd)/notebook:/workspace/notebook keras-mninst
[I 15:05:13.937 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 15:05:14.364 NotebookApp] Serving notebooks from local directory: /workspace
[I 15:05:14.364 NotebookApp] 0 active kernels
[I 15:05:14.365 NotebookApp] The Jupyter Notebook is running at:
[I 15:05:14.365 NotebookApp]
[I 15:05:14.366 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 15:05:14.367 NotebookApp] No web browser found: could not locate runnable browser.
[C 15:05:14.367 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:

cannot believe how important the . is in docker build -t keras-mnist .

that’s Unix for you :wink:

The final project is crashing on my iPhone when I draw something and I tap predict. It crashes here: fatalError(“Can’t get best result.”)

does it run ok in the simulator?

what model iPhone do you have?

Yes I can verify that it works on the simulator and on an iPhone SE but it crashes on iPhone X…

how strange! but then, the X has been having a few problems … maybe you could report it to Apple?

update: my friend-with-iPhoneX has the same experience so it’s a question for Apple?

further update:

No difference if you switch 3D off. Note if you write nothing it Predicts. If you tap dots it predicts but if you draw lines or write a number in one swipe it crashes

one more update: another dev friend tried inverting the DrawView colors, and got a non-nil CIImage that way.

This is quite the tutorial on ML. I suspect most iOS programmers won’t have a thorough grounding in the topic. I would strongly recommend the following from Coursera to get a decent grasp of the fundamentals.

1 Like

After run “import keras” command, then happen "The kernel appears to have died. It will restart automatically."
Have any hardware requirements ?

When I google that error, most of the results talk about insufficient memory or conflicting versions of jupyter etc. It’s unlikely you’ve run out of memory right at the start. Do you have other python stuff on your Mac? Although running the docker image should avoid version conflicts …

Try restarting your Mac?

I don’t know what wrong, but I try to reinstall docker and do again, then everything is ok. Thank you for your help.

I am not familiar with docker so I am attempting to follow the tutorial. When I execute the command:

docker build -t keras-mnist .

I get the error:

Package ipython-notebook is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘ipython-notebook’ has no installation candidate
The command ‘/bin/sh -c apt-get update && apt-get install -y wget python2.7 python-pip python-dev ipython ipython-notebook && rm -rf /var/lib/apt/lists/*’ returned a non-zero code: 100

Any idea what I am doing wrong?

hi, thanks for telling me about this!

ipython-notebook renamed itself jupyter, so that’s what needs to be installed. I’ve updated the starter folder with the new Dockerfile.

I also had to add a command to install tzdata before the other items, or the installation would stall when it asks for your geographic area.

Ubuntu! :expressionless:

It seems that keras is not installed.
On import keras statement, I obtain:

MemoryError Traceback (most recent call last)
in ()
2 from matplotlib import pyplot as plt
----> 4 import keras

/usr/local/lib/python2.7/dist-packages/keras/ in ()
1 from future import absolute_import
----> 3 from . import utils
4 from . import activations
5 from . import applications

/usr/local/lib/python2.7/dist-packages/keras/utils/ in ()
1 from future import absolute_import
2 from . import np_utils
----> 3 from . import generic_utils
4 from . import data_utils
5 from . import io_utils


hi! I can’t replicate your error … I think it’s similar to alanwang’s problem, possible insufficient-memory? try restarting your computer, then just start docker and a browser, and nothing else?

I forgot to say that I started the docker container in an ubuntu server machine (instead of my mac). Could it depend on that?

that could be a reason, but ubuntu is docker’s “native” environment so if anything, it should work better?

but I suppose ubuntu can have low-memory problems too, so try rebooting?

I am getting below error while running the command
“docker run --rm -it -p 8888:8888 -v $(pwd)/notebook:/workspace/notebook keras-mnist”
docker: invalid reference format.
See ‘docker run --help’.