by pixtur / 2016-10-30
Some personal notes on how to setup all dependencies and run the example code.
It looks like installing modules via pip does frequently fail with the global defaul macOS python. This stackexange article suggests to install al local version, into /usr/local/bin
so that your pip
can run against a user-modifiable python framework:
brew install python
pip --version
brew linkapps python
After this, pip-installations should be done without sudo
.
The most effective way to install python libraries on macOS:
- Stackoverflow suggests
sudo easy_install pip
- Best way seems to be to download a complete stack from SciPy.org stack, let's try the graphical installer of Anacoda (404mb).
PIL (Python Imaging Library) adds many image processing features to Python. Pillow is a fork of PIL that adds some user-friendly features.
The installation of pillow from source seems to be tricky. It's not compatible with PIL. The easiest installation seems to be…
- Installing with pil:
pip install pillow
Keras: Deep Learning library for Theano and TensorFlow. Keras is a high-level neural networks library, written in Python and capable of running on top of either TensorFlow or Theano. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research.
- On keras.io the installations suggest to use
pip install keras
which seems to work painlessly. It's seems to be important to use the local user python (i.E. not running pip with sudo). - This Additional guide for using Keras with GPU on MacOS seems to e
- For some reason, keros didn't install tensor-flow correctly on the first try. After some trial and error, this seemed to work:
pip install --ignore-installed tensorflow
Machine Learning in Python: Simple and efficient tools for data mining and data analysis built on NumPy, SciPy, and matplotlib
- The Installation guide suggests pip:
pip install -U scikit-learn
The h5py package is a Pythonic interface to the HDF5 binary data format.
It lets you store huge amounts of numerical data, and easily manipulate that data from NumPy. For example, you can slice into multi-terabyte datasets stored on disk, as if they were real NumPy arrays. Thousands of datasets can be stored in a single file, categorized and tagged.
- In a comment on this guide to keras somebody suggested pip, which did the trick:
pip install h5py
- Sadly, the suggested installation guide via Anaconda:
conda install h5py
didn't work for me, because python couldn't resolve the lib-import.
This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition. It has been obtained by directly converting the Caffe model provived by the authors.
On the description of the git-repository, Gene mentions the weights for the “VGG16 convnet”. The download is roughly 600MB.
- Follow YouYube-Video
- Clone repro:
git clone https://github.com/genekogan/image-tSNE.git
>>> # load model
... model = VGG_16()
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "cnnTSNE.py", line 45, in VGG_16
model.add(MaxPooling2D(pool_size=(2,2), strides=(2,2), dim_ordering='tf'))
File "/Library/Python/2.7/site-packages/keras/models.py", line 308, in add
output_tensor = layer(self.outputs[0])
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 514, in __call__
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 149, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/Library/Python/2.7/site-packages/keras/layers/pooling.py", line 162, in call
dim_ordering=self.dim_ordering)
File "/Library/Python/2.7/site-packages/keras/layers/pooling.py", line 212, in _pooling_function
border_mode, dim_ordering, pool_mode='max')
File "/Library/Python/2.7/site-packages/keras/backend/tensorflow_backend.py", line 1701, in pool2d
x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
File "/Library/Python/2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 850, in max_pool
name=name)
File "/Library/Python/2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1440, in _max_pool
data_format=data_format, name=name)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
op_def=op_def)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 2382, in create_op
set_shapes_for_outputs(ret)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 1783, in set_shapes_for_outputs
shapes = shape_func(op)
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 596, in call_cpp_shape_fn
raise ValueError(err.message)
ValueError: Negative dimension size caused by subtracting 2 from 1
Sadly, these suggestions don't fix the problem. This is proabably caused by a version conflict between the keras and the vgg16 setup.