Thursday, September 17, 2015

Theano + Lasagne on Azure Machine Learning

This is a note on how I set up Theano + Lasagne on Azure Machine Learning

1. Install Anaconda Python

2. From your windows command prompt:
c:
mkdir "C:\temp\Script Bundle\Python27\site-packages"
cd C:\temp\Script Bundle
git clone git://github.com/Theano/Theano.git theano_src
git clone https://github.com/Lasagne/Lasagne.git lasagne_src
set PYTHONUSERBASE=c:\temp\Script Bundle
cd C:\temp\Script Bundle\theano_src
pip install -e . --no-deps --user
cd C:\temp\Script Bundle\lasagne_src
pip install -e . --no-deps --user

3. Edit C:\temp\Script Bundle\theano_src\Theano.egg-info\requires.txt
Change the requirement line for six to read:
six>=1.6.1


4. Zip up the contents of C:\temp\Script Bundle
Upload it to Azure ML as a new dataset

5. Create a new Azure ML Experiment
Include your uploaded zip dataset
Include a "Execute Python Script" module

6. In your "Execute Python Script" module, include the following as a header:
import os
import os.path
import pkg_resources
import sys
SCRIPT_DIR = os.path.join(os.getcwd(), 'Script Bundle')
SITE_DIR = os.path.join(SCRIPT_DIR, 'Python27', 'site-packages')
siteEnv = pkg_resources.Environment([SITE_DIR])
packages, pkgErrors = pkg_resources.working_set.find_plugins(siteEnv)
for pkg in packages:
    print "Loading", pkg
    pkg_resources.working_set.add(pkg) # add plugins+libs to sys.path
if pkgErrors:
    print "Couldn't load", pkgErrors # display errors
# Set Theano variable to disable warning messages
os.environ['THEANO_FLAGS'] = 'cxx='
os.environ['OMP_NUM_THREADS'] = '4'

3 comments:

Unknown said...

Hello!
I am trying to use Theano + Keras on Azure ML Studio.

I followed your article and faced an issue when implementing a simple experiment.
It seems that Theano model is not cached and is recompiled at every run of experiment — so it takes a lot of time, obviously.

Did you have the same issue?
And if you did: did you manage to solve that problem?

Blogger said...

If you're trying to lose weight then you certainly need to jump on this brand new personalized keto meal plan.

To design this service, certified nutritionists, personal trainers, and professional cooks have joined together to develop keto meal plans that are efficient, painless, price-efficient, and fun.

Since their launch in early 2019, 1000's of people have already remodeled their body and well-being with the benefits a smart keto meal plan can give.

Speaking of benefits: clicking this link, you'll discover eight scientifically-tested ones provided by the keto meal plan.

Ramesh Sampangi said...

Sign up for the advanced Machine Learning Training in Hyderabad program offered by AI Patasala and work towards getting successfully hired a Machine Learning expert.
Machine Learning Institute in Hyderabad