Giter Site home page Giter Site logo

kaggle_diabetic's Introduction

Kaggle Diabetic Retinopathy Detection

Installation

Extract train/test images to data/train and data/test respectively and put the trainLabels.csv file into the data directory as well.

Install python2 dependencies via,

pip install -r requirements.txt

You need a CUDA capable GPU with at least 4GB of video memory and CUDNN installed.

If you'd like to run a deterministic variant you can use the deterministic branch. Note that the branch has its own requirements.txt file. In order to achieve determinism cuda-convnet is used for convolutions instead of cuDNN. The deterministic version increases the GPU memory requirements to 6GB and takes about twice as long to run.

The project was developed and tested on arch linux and hardware with a i7-2600k CPU, GTX 970 and 980Ti GPUs and 32 GB RAM. You probably need at least 8GB of RAM as well as up to 160 GB of harddisk space (for converted images, network parameters and extracted features) to run all the code in this repository.

Usage

Generating the kaggle solution

A commented bash script to generate our final 2nd place solution can be found in make_kaggle_solution.sh.

Running all the commands sequentially will probably take 7 - 10 days on recent consumer grade hardware. If you have multiple GPUs you can speed things up by doing training and feature extraction for the two networks in parallel. However, due to the computationally heavy data augmentation it may be far less than twice as fast especially when working with 512x512 pixel input images.

You can also obtain a quadratic weighted kappa score of 0.839 on the private leaderboard by just training the 4x4 kernel networks and by performing only 20 feature extraction iterations with the weights that gave you the best MSE validation scores during training. The entire ensemble only achieves a slightly higher score of 0.845.

Scripts

All these python scripts can be invoked with --help to display a brief help message. They are meant to be executed in the order,

  • convert.py crops and resizes images
  • train_nn.py trains convolutional networks
  • transform.py extracts features from trained convolutional networks
  • blend.py blends features, optionally blending inputs from both patient eyes
convert.py

Example usage:

python convert.py --crop_size 128 --convert_directory data/train_tiny --extension tiff --directory data/train
python convert.py --crop_size 128 --convert_directory data/test_tiny --extension tiff --directory data/test
Usage: convert.py [OPTIONS]

Options:
  --directory TEXT          Directory with original images.  [default: data/train]
  --convert_directory TEXT  Where to save converted images.  [default: data/train_res]
  --test                    Convert images one by one and examine them on screen.  [default: False]
  --crop_size INTEGER       Size of converted images.  [default: 256]
  --extension TEXT          Filetype of converted images.  [default: tiff]
  --help                    Show this message and exit
train_nn.py

Example usage:

python train_nn.py --cnf configs/c_128_5x5_32.py
python train_nn.py --cnf configs/c_512_5x5_32.py --weights_from weigts/c_256_5x5_32/weights_final.pkl
Usage: train_nn.py [OPTIONS]

Options:
  --cnf TEXT           Path or name of configuration module.  [default: configs/c_512_4x4_tiny.py]
  --weights_from TEXT  Path to initial weights file.
  --help               Show this message and exit.
transform.py

Example usage:

python transform.py --cnf config/c_128_5x5_32.py --train --test --n_iter 5
python transform.py --cnf config/c_128_5x5_32.py --n_iter 5 --test_dir path/to/other/image/files
python transform.py --test_dir path/to/alternative/test/files
Usage: transform.py [OPTIONS]

Options:
  --cnf TEXT           Path or name of configuration module.  [default: configs/c_512_4x4_32.py]
  --n_iter INTEGER     Iterations for test time averaging.  [default: 1]
  --skip INTEGER       Number of test time averaging iterations to skip. [default: 0]
  --test               Extract features for test set. Ignored if --test_dir is specified.  [default: False]
  --train              Extract features for training set.  [default: False]
  --weights_from TEXT  Path to weights file.
  --test_dir TEXT      Override directory with test set images.
  --help               Show this message and exit.
blend.py

Example usage:

python blend.py --per_patient # use configuration in blend.yml
python blend.py --per_patient --feature_file path/to/feature/file
python blend.py --per_patient --test_dir path/to/alternative/test/files

Usage: blend.py [OPTIONS]

Options:
  --cnf TEXT            Path or name of configuration module.  [default: configs/c_512_4x4_32.py]
  --predict             Make predictions on test set features after training. [default: False]
  --per_patient         Blend features of both patient eyes.  [default: False]
  --features_file TEXT  Read features from specified file.
  --n_iter INTEGER      Number of times to fit and average.  [default: 1]
  --blend_cnf TEXT      Blending configuration file.  [default: blend.yml]
  --test_dir TEXT       Override directory with test set images.
  --help                Show this message and exit.

Configuration

  • The convolutional network configuration is done via the files in the configs directory.
  • To select different combinations of extracted features for blending edit blend.yml.
  • To tune parameters related to blending edit blend.py directly.
  • To make predictions for a different test set either
    • put the resized images into the data/test_medium directory
    • or edit the test_dir field in your config file(s) inside the configs directory
    • or pass the --test_dir /path/to/test/files argument to transform.py and blend.py

kaggle_diabetic's People

Contributors

sveitser 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  avatar  avatar  avatar

kaggle_diabetic's Issues

Cuda and CuDNN version

I have installed everything from the requirements but am unable to run the training. The error I get is from CuDNN. I have installed with CUDA 8 and CuDNN of version 5,6,7 but nothing change. Can you specify the version of your CUDA and CuDNN? Thanks
P/S: it can load CuDNN backend

This is how the error looks like:
Exception: ('The following error happened while compiling the node', GpuDnnPoolDesc{ws=(3, 3), stride=(3, 3), mode='average_inc_pad', pad=(0, 0)}(), '\n', 'nvcc return status', 2, 'for cmd', 'nvcc -shared -O3 -arch=sm_30 -use_fast_math -m64 -Xcompiler -fno-math-errno,-Wno-unused-label,-Wno-unused-variable,-Wno-write-strings,-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/lab513/.theano/compiledir_Linux-4.15--gcp-x86_64-with-debian-stretch-sid-x86_64-2.7.15-64/cuda_ndarray -I/home/lab513/miniconda3/envs/teamOo/lib/python2.7/site-packages/theano/sandbox/cuda -I/home/lab513/miniconda3/envs/teamOo/lib/python2.7/site-packages/numpy/core/include -I/home/lab513/miniconda3/envs/teamOo/include/python2.7 -I/home/lab513/miniconda3/envs/teamOo/lib/python2.7/site-packages/theano/gof -o /home/lab513/.theano/compiledir_Linux-4.15--gcp-x86_64-with-debian-stretch-sid-x86_64-2.7.15-64/tmp4HJcPh/3afb1fddac0ed875e1424ddbcfb07a41.so mod.cu -L/home/lab513/miniconda3/envs/teamOo/lib -lpython2.7 -lcudnn -lcudart', "[GpuDnnPoolDesc{ws=(3, 3), stride=(3, 3), mode='average_inc_pad', pad=(0, 0)}()]")

Can I Run this Code?

hi mathis
I have a question
I have a system with specifications:
cpu corei7
ram 8 gig
vga:geforce 550m 2 gig(not support cudNNa)
windows 10
can I run your code in my system with my cpu only?you said for running on cpu we should use deterministc branch,but you said for this we need 6 gig of vga memory!but my vga card has only 2 gig memory

why blur?

hi,
I am so appreciated with your great job. And i have read your code carefully.
When i read the convert.py, it confused me in
" blurred = img.filter(ImageFilter.BLUR)
ba = np.array(blurred)"

why should blur the image?
look forward to your reply.
thanks.

Some questions on your conv. n.n. architecture and blend network

Dear Mathis,

I have implemented the conv. net. according to your documentation in (https://www.kaggle.com/blobs/download/forum-message-attachment-files/2797/report.pdf) as follows, albeit with some modifications to make it good (I think) for an small dataset of 1000 elements of training set (the distribution of all 5 classes are approximately equal).

1- In your convolutional network, the output of your network is a 512 element vector, the maxout layer. As far as I know from the NN, we need a label for every input to the network. So, what is the label here?

2- The number of inputs to your blend network is 8193. How did you come with this number?

My code is as follow:

import sys
import os
import time

import numpy as np
import theano
import theano.tensor as T

import lasagne

import pandas as pd
from PIL import Image

input_var = T.tensor4('inputs')
target_var = T.ivector('targets')

network = lasagne.layers.InputLayer(shape=(np.newaxis, 3, 512, 512),
                                        input_var=input_var)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=8, filter_size=(5, 5),
            nonlinearity=lasagne.nonlinearities.rectify,
            W=lasagne.init.GlorotUniform(),
            stride=(2, 2))#, pad=1)#, partial_sum=2)
# network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2))
network = lasagne.layers.Conv2DLayer(
            network, num_filters=8, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=16, filter_size=(5, 5),
            nonlinearity=lasagne.nonlinearities.rectify,
            W=lasagne.init.GlorotUniform(),
            stride=(2, 2))#, pad=1)#, partial_sum=2)
# network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2))
network = lasagne.layers.Conv2DLayer(
            network, num_filters=16, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=16, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=32, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=32, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=32, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=64, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=64, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=64, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.Conv2DLayer(
            network, num_filters=128, filter_size=(3, 3),
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.MaxPool2DLayer(network, pool_size=(3,3), stride=2)
network = lasagne.layers.DenseLayer(
            lasagne.layers.dropout(network, p=.5),
            num_units=128,
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.FeaturePoolLayer(network, pool_size=2)

network = lasagne.layers.DenseLayer(
            lasagne.layers.dropout(network, p=.5),
            num_units=128,
            nonlinearity=lasagne.nonlinearities.rectify)
network = lasagne.layers.FeaturePoolLayer(network, pool_size=2)

network = lasagne.layers.DenseLayer(
            lasagne.layers.dropout(network, p=.5),
            num_units=5,
            nonlinearity=lasagne.nonlinearities.softmax)
prediction = lasagne.layers.get_output(network)
loss = lasagne.objectives.categorical_crossentropy(prediction, target_var)
loss = loss.mean()
params = lasagne.layers.get_all_params(network, trainable=True)
updates = lasagne.updates.nesterov_momentum(
        loss, params, learning_rate=0.01, momentum=0.9)
test_prediction = lasagne.layers.get_output(network, deterministic=True)
test_loss = lasagne.objectives.categorical_crossentropy(test_prediction,
      target_var)
test_loss = test_loss.mean()
# As a bonus, also create an expression for the classification accuracy:
test_acc = T.mean(T.eq(T.argmax(test_prediction, axis=1), target_var),
      dtype=theano.config.floatX)

# Compile a function performing a training step on a mini-batch (by giving
# the updates dictionary) and returning the corresponding training loss:
train_fn = theano.function([input_var, target_var], loss, updates=updates)

# Compile a second function computing the validation loss and accuracy:
val_fn = theano.function([input_var, target_var], [test_loss, test_acc])
params = lasagne.layers.get_all_params(network, trainable=True)
updates = lasagne.updates.nesterov_momentum(
        loss, params, learning_rate=0.001, momentum=0.9)
test_prediction = lasagne.layers.get_output(network, deterministic=True)
test_loss = lasagne.objectives.categorical_crossentropy(test_prediction,
      target_var)
test_loss = test_loss.mean()
# As a bonus, also create an expression for the classification accuracy:
test_acc = T.mean(T.eq(T.argmax(test_prediction, axis=1), target_var),
      dtype=theano.config.floatX)

# Compile a function performing a training step on a mini-batch (by giving
# the updates dictionary) and returning the corresponding training loss:
train_fn = theano.function([input_var, target_var], loss, updates=updates)

# Compile a second function computing the validation loss and accuracy:
val_fn = theano.function([input_var, target_var], [test_loss, test_acc])
def iterate_minibatches(inputs, targets, batchsize, shuffle=False):
    # assert len(inputs) == len(targets)
    if shuffle:
        indices = np.arange(len(inputs))
        np.random.shuffle(indices)
    for start_idx in range(0, len(inputs) - batchsize + 1, batchsize):
        if shuffle:
            excerpt = indices[start_idx:start_idx + batchsize]
        else:
            excerpt = slice(start_idx, start_idx + batchsize)
        # yield inputs[excerpt,:,:,:], targets[excerpt,:,:,:]
        yield inputs[excerpt,:,:,:], targets[excerpt]
BASE_TRAIN_DIR = r'/home/ali/DiabeticRethinopathy/diabeticrethinopathy/data/train/'
train_labels = pd.read_csv(r'/home/ali/DiabeticRethinopathy/diabeticrethinopathy/data/train.csv', sep=',')
train_data = []
tc = 0
for id in train_labels['image']:
    tc += 1
    train_data.append(np.array(Image.open(os.path.join(BASE_TRAIN_DIR, id + '.tiff'))).T)
train_data = np.array(train_data).astype("float32") / 255.0
trainLABELS = np.zeros((tc,5))
i = 0
for lbl in train_labels['level'].values:
    trainLABELS[i][lbl] = 1
    i += 1

BASE_TEST_DIR = r'/home/ali/DiabeticRethinopathy/diabeticrethinopathy/data/test/'
test_labels = pd.read_csv(r'/home/ali/DiabeticRethinopathy/diabeticrethinopathy/data/test.csv', sep=',')
test_data = []
tc = 0
for id in test_labels['image']:
    tc += 1 
    test_data.append(np.array(Image.open(os.path.join(BASE_TEST_DIR, id + '.tiff'))).T)
test_data = np.array(test_data).astype("float32") / 255.0
testLABELS = np.zeros((tc,5))
i = 0
for lbl in test_labels['level'].values:
    testLABELS[i][lbl] = 1
    i += 1
num_epochs = 10
X_train = train_data[:960,:,:,:]
y_train = train_labels['level'].values.astype("uint8")[:960]
X_val = test_data[:960,:,:,:]
y_val = test_labels['level'].values.astype("uint8")[:960]
X_test = test_data[:960,:,:,:]
y_test = test_labels['level'].values.astype("uint8")[:960]
for epoch in range(num_epochs):
    # In each epoch, we do a full pass over the training data:
    train_err = 0
    train_batches = 0
    start_time = time.time()
    for batch in iterate_minibatches(X_train, y_train, 32, shuffle=True):
        print '*',
        inputs, targets = batch
        train_err += train_fn(inputs, targets)
        train_batches += 1
    print '$'
    # And a full pass over the validation data:
    val_err = 0
    val_acc = 0
    val_batches = 0
    for batch in iterate_minibatches(X_val, y_val, 32, shuffle=True):
        inputs, targets = batch
        err, acc = val_fn(inputs, targets)
        val_err += err
        val_acc += acc
        val_batches += 1
        print '+',
        if val_batches > 1:
            break
    print '$'

    # Then we print the results for this epoch:
    print("Epoch {} of {} took {:.3f}s".format(
        epoch + 1, num_epochs, time.time() - start_time))
    if train_batches == 0:
        train_batches = -1
    if val_batches == 0:
        val_batches = -1
    print("  training loss:\t\t{:.6f}".format(train_err / train_batches))
    print("  validation loss:\t\t{:.6f}".format(val_err / val_batches))
    print("  validation accuracy:\t\t{:.2f} %".format(
        val_acc / val_batches * 100))

# After training, we compute and print the test error:
test_err = 0
test_acc = 0
test_batches = 0
for batch in iterate_minibatches(X_test, y_test, 32, shuffle=False):
    inputs, targets = batch
    err, acc = val_fn(inputs, targets)
    test_err += err
    test_acc += acc
    test_batches += 1
print("Final results:")
if test_batches == 0:
    test_batches = -1
print("  test loss:\t\t\t{:.6f}".format(test_err / test_batches))
print("  test accuracy:\t\t{:.2f} %".format(
    test_acc / test_batches * 100))

Objective class in lasagne.objectives is deprecated and is removed

Hi there,

Unfortunately, the code does not run! The error is caused by the line 7 of nn.py file for (this reason)[https://github.com/Lasagne/Lasagne/commit/904ae297da863a7864c6c244a1cc01b70aad9753]. I have used to from nolearn.lasagne import objective and then do a trick of Objective = objective. Although this helps in getting rid of these errors, but I encounter another error on the first line of get_objective method in nn.py file.

 TypeError: Error when calling the metaclass bases
 function() argument 1 must be code, not str

I cannot fix it yet. Would you mind publish a patch for your code! or help me to run it.

error in pip install -r requirements.txt

Hello Mathis,

this is the error code when "
pip install -r requirements.txt" , any suggest on this (this in OSX)

building 'SharedArray' extension
gcc -fno-strict-aliasing -I/Users/Daniel/anaconda2/envs/kaggle1/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/Daniel/anaconda2/envs/kaggle1/include/python2.7 -c /var/folders/x3/j4dr5xhx1sq08x5q4r8kzdyw0000gn/T/pip-1me7Jj-build/src/shared_array.c -o build/temp.macosx-10.5-x86_64-2.7/var/folders/x3/j4dr5xhx1sq08x5q4r8kzdyw0000gn/T/pip-1me7Jj-build/src/shared_array.o
/var/folders/x3/j4dr5xhx1sq08x5q4r8kzdyw0000gn/T/pip-1me7Jj-build/src/shared_array.c:24:10: fatal error: 'numpy/arrayobject.h' file not found
#include <numpy/arrayobject.h>
^
1 error generated.
error: command 'gcc' failed with exit status 1

Hyperparameter optimization

Hello Mathis:

I ran through your solution using Intel® Core™ i5 CPU 760 @ 2.80GHz × 4 and GeForce GTX 970/PCIe/SSE2 under Ubuntu 14.04 LTS in about 18days, got kappa value shown in the attached which is similar as you did in the competition. I am planning either to go further with hyperparameter optimization or adjusting network depth or width. Any suggestion on this?

Cheers,

Daniel

screenshot from 2016-02-08 14 40 19

Dump of model?

Hello,

Would you be willing to consider sharing a dump of your model so that I could test it without having to get GPU access for 7-10 days?

Thank you!
Sam

ImportError: No module named configs.c_128_5x5_32

Hello Mathis, please check the message below executed with train_nn.py with the importerror:No module named configs.c_128_5x5_32

(kaggleDR-env)danieleewww@Ubuntuwww:~/Documents/KaggleDR$ ./make_kaggle_solution.sh
Resizing images in data/train to data/train_medium, this takes a while.
batch  1 / 71
batch  2 / 71
.......
batch 70 / 71
batch 71 / 71
done
Using gpu device 0: GeForce GTX 970 (CNMeM is disabled)
/home/danieleewww/Documents/KaggleDR/src/theanopip/theano/tensor/signal/downsample.py:5: UserWarning: downsample module has been moved to the pool module.
  warnings.warn("downsample module has been moved to the pool module.")
Traceback (most recent call last):
  File "train_nn.py", line 40, in <module>
    main()
  File "/home/danieleewww/anaconda2/envs/kaggleDR-env/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/home/danieleewww/anaconda2/envs/kaggleDR-env/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/home/danieleewww/anaconda2/envs/kaggleDR-env/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/danieleewww/anaconda2/envs/kaggleDR-env/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "train_nn.py", line 17, in main
    config = util.load_module(cnf).config
  File "/home/danieleewww/Documents/KaggleDR/util.py", line 33, in load_module
    return importlib.import_module(mod.replace('/', '.').split('.py')[0])
  File "/home/danieleewww/anaconda2/envs/kaggleDR-env/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named configs.c_128_5x5_32

my pip list:

(kaggleDR-env)danieleewww@Ubuntuwww:~/Documents/KaggleDR$ pip list
click (3.3)
decorator (4.0.6)
funcsigs (0.4)
ghalton (0.6)
joblib (0.9.4)
Lasagne (0.1.dev0, /home/danieleewww/Documents/KaggleDR/src/lasagne-master)
matplotlib (1.4.3)
mock (1.3.0)
networkx (1.10)
nolearn (0.6a0.dev0, /home/danieleewww/Documents/KaggleDR/src/nolearn-master)
nose (1.3.7)
numpy (1.10.4)
pandas (0.17.1)
pbr (1.8.1)
Pillow (2.7.0)
pip (7.1.2)
pyparsing (2.0.7)
python-dateutil (2.4.2)
pytz (2015.7)
PyYAML (3.11)
scikit-image (0.11.3)
scikit-learn (0.16.1)
scipy (0.15.1)
setuptools (19.2)
SharedArray (0.2)
six (1.10.0)
tabulate (0.7.5)
Theano (0.8.0.dev0, /home/danieleewww/Documents/KaggleDR/src/theanopip)
wheel (0.26.0)

lasagne and nolearn version

When I run this code I get following error which I believe is happening because of version conflict of lasagne or nolearn between build and present version. Could you tell me what version or commit-point of lasagne and nolearn you have used in this project.

File "/home/tanay/src/lasagne/lasagne/layers/conv.py", line 391, in init
super(Conv2DLayer, self).init(incoming, **kwargs)

TypeError: Failed to instantiate <class 'lasagne.layers.conv.Conv2DLayer'> with args {'b': <lasagne.init.Constant object at 0x7fab337e74d0>, 'incoming': <lasagne.layers.input.InputLayer object at 0x7fab31f54390>, 'name': 'conv2d1', 'nonlinearity': <lasagne.nonlinearities.LeakyRectify object at 0x7fab3b5e0250>, 'filter_size': (4, 4), 'stride': (2, 2), 'W': <lasagne.init.Orthogonal object at 0x7fab337e7450>, 'num_filters': 32, 'untie_biases': True, 'border_mode': 'same'}.
Maybe parameter names have changed?

AttributeError: mode

ubuntu@ip-172-31-33-63:~/kellogs/kaggle_diabetic$ python train_nn.py --cnf configs/c_128_5x5_32.py
failed to load CUDNN backend
failed to load CUDAConvNet backend
using CPU backend
{'aug_params': {'allow_stretch': True,
'do_flip': True,
'rotation_range': (0, 360),
'shear_range': (0, 0),
'translation_range': (-40, 40),
'zoom_range': (0.8695652173913044, 1.15)},
'balance_ratio': 0.975,
'balance_weights': array([ 1.36094537, 14.3782235 , 6.63756614, 40.23596793, 49.61299435]),
'batch_size_test': 128,
'batch_size_train': 128,
'final_balance_weights': array([ 1., 2., 2., 2., 2.]),
'h': 112,
'name': 'c_128_5x5_32',
'schedule': {0: 0.003, 150: 0.0003, 201: 'stop'},
'sigma': 0.5,
'test_dir': 'data/test_tiny',
'train_dir': 'data/train_tiny',
'w': 112,
'weight_decay': 0.0005}
Traceback (most recent call last):
File "train_nn.py", line 40, in
main()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
return callback(*args, **kwargs)
File "train_nn.py", line 31, in main
net.load_params_from(weights_from)
File "/home/ubuntu/kellogs/kaggle_diabetic/src/nolearn-master/nolearn/lasagne/base.py", line 487, in load_params_from
self.initialize()
File "/home/ubuntu/kellogs/kaggle_diabetic/nn.py", line 131, in initialize
out = self._output_layer = self.initialize_layers()
File "/home/ubuntu/kellogs/kaggle_diabetic/src/nolearn-master/nolearn/lasagne/base.py", line 265, in initialize_layers
layer = layer_factory(**layer_kw)
File "/home/ubuntu/kellogs/kaggle_diabetic/layers.py", line 81, in init
del self.mode
AttributeError: mode

How to resolve this error?

Error when using CPU mode

when using CPU mode, an error occured in layers.py, line 81, in init del sel.,mode
AtttributeError: mode occured

when i change the number of train pictures,I got error

At first i put 1000 photos in data/train ,then i run "python train_nn.py --cnf configs/c_128_5x5_32.py",there is nothing wrong, but when i put 35000 photos in data/train, i got error, I sure i have changed the labels too,failed as this:
Traceback (most recent call last):
File "train_nn.py", line 41, in
main()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "train_nn.py", line 38, in main
net.fit(files, labels)
File "/usr/local/lib/python2.7/dist-packages/nolearn-0.6a0.dev0-py2.7.egg/nolearn/lasagne/base.py", line 416, in fit
self.train_loop(X, y)
File "/home/zcx/kaggle_diabetic-deterministic/nn.py", line 219, in train_loop
X, y, self.eval_size)
File "/home/zcx/kaggle_diabetic-deterministic/nn.py", line 126, in train_test_split
X, y, test_size=eval_size)
File "/home/zcx/kaggle_diabetic-deterministic/data.py", line 293, in split
train, test = split_indices(files, labels, test_size, random_state)
File "/home/zcx/kaggle_diabetic-deterministic/data.py", line 281, in split_indices
labels = get_labels(names, per_patient=True)
File "/home/zcx/kaggle_diabetic-deterministic/data.py", line 222, in get_labels
return np.vstack([labels[left], labels[~left]]).T
File "/usr/local/lib/python2.7/dist-packages/numpy/core/shape_base.py", line 228, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
ValueError: all the input array dimensions except for the concatenation axis must match exactly
what should i do? can you give me some advice?

Please help me, I'm obviously an indiot

[RESOLVED} - I am an idiot! Forgot to convert the train_tiny set.....
Sorry for anyone who paid any attention to my madness!

I have been struggling for two weeks to get your code to run for a project for my degree.
I finally have it almost there.
I'm using Ubuntu 14.04 have used virtualenv and managed to install requirements.txt manually one by one as for some reason i keep getting issues other ways. CUDNN backend is working and the code runs on the GPU.

edit: I couldn't install Shared Array 0.2 but can install 0.3? perhaps this is the issue?
edit: solved this but still having the same problem as described below.

When I try to run train_nn I get:
Traceback (most recent call last):
File "train_nn.py", line 40, in
main()
File "/home/mike/.virtualenvs/test/local/lib/python2.7/site-packages/click/core.py", line 610, in call
return self.main(_args, *_kwargs)
File "/home/mike/.virtualenvs/test/local/lib/python2.7/site-packages/click/core.py", line 590, in main
rv = self.invoke(ctx)
File "/home/mike/.virtualenvs/test/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
return ctx.invoke(self.callback, *_ctx.params)
File "/home/mike/.virtualenvs/test/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
return callback(_args, **kwargs)
File "train_nn.py", line 37, in main
net.fit(files, labels)
File "/home/mike/.virtualenvs/test/src/nolearn-master/nolearn/lasagne/base.py", line 334, in fit
self.train_loop(X, y)
File "/media/mike/Data/kaggleDR/nn.py", line 208, in train_loop
X, y, self.eval_size)
File "/media/mike/Data/kaggleDR/nn.py", line 118, in train_test_split
X, y, test_size=eval_size)
File "/media/mike/Data/kaggleDR/data.py", line 291, in split
train, test = split_indices(files, labels, test_size, random_state)
File "/media/mike/Data/kaggleDR/data.py", line 279, in split_indices
labels = get_labels(names, per_patient=True)
File "/media/mike/Data/kaggleDR/data.py", line 221, in get_labels
return np.vstack([labels[left], labels[~left]]).T
IndexError: arrays used as indices must be of integer (or boolean) type

Please help me, I am desperate to understand this!

Error with CudaConvnet mode

While executing the programme in CudaCovnet mode, there are errors:
File "/home/lincoln/desktop/DRCuda/layers.py", line 24, in
Pool2DLayer = lasagne.layers.cuda_convnet.Pool2DLayer
AttributeError: 'module' object has no attribute 'Pool2DLayer'
After looking into the problem, lthere isn't a class named Pool2DLayer in cuda_convnet.py from lasagne/layers/

Some errors in data.py file

Hi there,

There are two errors in file data.py:

  • on line 202, the method load_image_uint is not defined. However, the project works well since the method std defined on line 196 is never called in the project, :). I have searched for the method, but it does not exist.
  • on line 149 in method load_perturbed, the file util is not imported, This can be solved by importing impot util just before that line.

Thanks for sharing your ideas.

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.