Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Prepare sc for py transform (#35)
Browse files Browse the repository at this point in the history
* enable notebook on bigdl_0.3.0 and spark_2.2

* changes according to code changes

* remove changes on start_notebook.sh

* 0.3.0 notebook work

* Fix docs

* unsaved changes

* change README address for 0.3.0 download

* change README

* prepare sc for jenkins

* fix matplotlib import

* declare utf-8 coding

* more declares

* spark conf to avoid OOM

* change to directly use jupyter

* specify version 0.3.0 , delete spark install in Setup.md for pyspark will be installed with pip

* setup changes

* setup changes
  • Loading branch information
chengxuHawkwood authored and yiheng-wang-intel committed Nov 9, 2017
1 parent 720acf3 commit 8478159
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 110 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ Step-by-step Deep Leaning Tutorials on Apache Spark using [BigDL](https://github
+ [Setup env on Mac OS](https://github.com/intel-analytics/BigDL-Tutorials/blob/master/SetupMac.md) / [Setup env on Linux](https://github.com/intel-analytics/BigDL-Tutorials/blob/master/SetupLinux.md)

### Start Jupyter Server
* Download BigDL 0.3.0([linux or mac](https://repo1.maven.org/maven2/com/intel/analytics/bigdl/dist-spark-2.2.0-scala-2.11.8-linux64/0.3.0/dist-spark-2.2.0-scala-2.11.8-linux64-0.3.0-dist.zip )) and unzip file.
* Run ```export BIGDL_HOME=where is your unzipped bigdl folder```
* Run ```export SPARK_HOME=where is your unpacked spark folder```
* Run ```./start_notebook.sh```
* Run ```pip install BigDL==0.3.0```
* Run ``` jupyter notebook --notebook-dir=./ --ip=* --no-browser```

## Run Demo
* Open a browser - Suggest Chrome or Firefox or Safari
Expand Down
8 changes: 6 additions & 2 deletions SetupLinux.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ This guide is mainly for Ubuntu. If you has other linux platform, please do the

### Installation Steps

* Install Java and Spark
* Install Java
* Install Jdk 8 from http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk
* Install Spark 2.1.0 from http://spark.apache.org/downloads.html
* Run the following steps
```
export JAVA_HOME=where you unzip your jdk
export PATH=$PATH:$JAVA_HOME/bin
```
* Install Python dev env. Python2.7 is shipped with linux.
```
sudo apt-get update
Expand Down
7 changes: 5 additions & 2 deletions SetupMac.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
```
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
* Install Java and Spark
* Install Java
* Install Java on OSX following the guide https://java.com/en/download/help/mac_install.xml
* Install Spark on OSX http://spark.apache.org/downloads.html
```
export JAVA_HOME=where you unzip your jdk
export PATH=$PATH:$JAVA_HOME/bin
```
* (Optional) (Mac) Install Python. Python is shipped with MacOS, but you may want to install updates using Homebrew
```
brew install python
Expand Down
3 changes: 2 additions & 1 deletion ipynb2py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Example:
# ipynb2py notebooks/neural_networks/rnn
#########################################

if [ $# -ne "1" ]; then
echo "Usage: ./nb2script <file-name without extension>"
else
Expand All @@ -17,5 +16,7 @@ else
jupyter nbconvert --to script $1.tmp.ipynb

mv $1.tmp.py $1.py
sed -i '1i# -*- coding: utf-8 -*-' $1.py
sed -i '#!/usr/bin/python' $1.py
rm $1.tmp.ipynb
fi
25 changes: 16 additions & 9 deletions notebooks/neural_networks/autoencoder.ipynb

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions notebooks/neural_networks/birnn.ipynb

Large diffs are not rendered by default.

39 changes: 23 additions & 16 deletions notebooks/neural_networks/cnn.ipynb

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions notebooks/neural_networks/deep_feed_forward_neural_network.ipynb

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions notebooks/neural_networks/introduction_to_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
"Populating the interactive namespace from numpy and matplotlib\n",
"Prepending /usr/local/lib/python2.7/dist-packages/bigdl/share/conf/spark-bigdl.conf to sys.path\n"
]
}
],
"source": [
"import matplotlib\n",
"matplotlib.use('Agg')\n",
"# As always, a bit of setup\n",
"%pylab inline\n",
"import pandas\n",
"from bigdl.dataset import mnist\n",
"from bigdl.util.common import *\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from pyspark import SparkContext\n",
"from matplotlib.pyplot import imshow\n",
"sc=SparkContext.getOrCreate(conf=create_spark_conf().setMaster(\"local[4]\").set(\"spark.driver.memory\",\"2g\"))\n",
"init_engine()"
]
},
Expand Down Expand Up @@ -106,15 +112,15 @@
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAABECAYAAACRbs5KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE09JREFUeJztnX9QVOUax7+LLFgiIkKCqVCZGXJ1g0ozRmWi1PSqTReV\nEbwwYz+sNJ2xlFHJYhxIp1BJC8zhjsjVCK1srtxqQI20mDRtmAo1MqDAH4MiRDuwZ8/3/uHsuayg\nLXDOQtvzmXn+2XP2PM95zznfffZ9n/c9JpIQBEEQ/vx49XYAgiAIgj6IoAuCIHgIIuiCIAgeggi6\nIAiChyCCLgiC4CGIoAuCIHgIIuiCIAgeggi6IAiChyCCLgiC4CF4u9OZyWSSaamCIAhdhKTJlf0k\nQxcEQfAQRNAFQRA8BBF0QRAED0EEXRAEwUMQQe8m0dHRiI6ORl5eHux2O/Ly8hAVFdXbYQl/UbZs\n2YItW7aAJCoqKhAWFtbbIQldpKSkBKWlpT07CEm3GQB2x/r168d+/foxMDBQs7S0NGZmZjIzM5Mf\nfPABhw0bxn//+98kSavVSqvVyldeeaVb/v7ILBYLL1++zMuXL1NRFM0aGhoM8dcde+SRR3j+/Hne\nc889vOeee9zqe+3atbTb7XQwZcqUXm8Pd9nAgQM5cOBAhoaG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pzhmTNnqCgK//Wvf+l23D9NH/qECRNYVFTEmpqa\nTkW8ubmZGzZs4IYNG7SXWxhtoaGhXL9+fQdBf+ONNwwZyNLD2veh/9UEHYD2EPX2WEZfsLCwMFZU\nVOgu6I7xpPaLjl1vp0+f5smTJ7l161ZtYlFvtkVdXR2tVivHjBnjFn+pqala/7mePyJ/GkHPzMzs\nIOIVFRXMyMhgenq64SsGeoolJyczOTnZkAw9JCSER44c6dOC7njxRUlJSZ+ovfZk8/X15TPPPMNL\nly5RUa69eaioqIjPPPPMDd9Y1Fu2d+9efvvtt31mAL+75qrGmtoPXBiNyWRynzPhL4W/vz8KCwsR\nFxeH/fv3AwBSUlIMXaBLENwFSZdejiqDooIgCJ5Cb3e5iInpZf7+/szOznaa9t7bMYmJ6WHS5SII\nguAhuNrl4lZBFwRBEIxD+tAFQRA8BBF0QRAED0EEXRAEwUMQQRcEQfAQRNAFQRA8BBF0QRAED0EE\nXRAEwUMQQRcEQfAQRNAFQRA8BBF0QRAED0EEXRAEwUMQQRcEQfAQRNAFQRA8BBF0QRAED0EEXRAE\nwUMQQRcEQfAQRNAFQRA8BBF0QRAED0EEXRAEwUMQQRcEQfAQRNAFQRA8BBF0QRAED0EEXRAEwUP4\nHxebd0nIMiF9AAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7fd41f480b50>"
"<matplotlib.figure.Figure at 0x7f7294f10c90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"imshow(np.column_stack(train_images[0:10].reshape(10, 28,28)),cmap='gray'); axis('off')\n",
"imshow(np.column_stack(train_images[0:10].reshape(10, 28,28)),cmap='gray'); plt.axis('off')\n",
"print \"groud true labels: \"\n",
"print train_labels[0:10]"
]
Expand Down
21 changes: 14 additions & 7 deletions notebooks/neural_networks/linear_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
"Populating the interactive namespace from numpy and matplotlib\n",
"Prepending /usr/local/lib/python2.7/dist-packages/bigdl/share/conf/spark-bigdl.conf to sys.path\n"
]
}
],
"source": [
"import matplotlib\n",
"matplotlib.use('Agg')\n",
"%pylab inline\n",
"import pandas\n",
"import datetime as dt\n",
Expand All @@ -37,7 +40,11 @@
"from bigdl.optim.optimizer import *\n",
"from bigdl.util.common import *\n",
"from bigdl.util.common import Sample\n",
"import matplotlib.pyplot as plt\n",
"from bigdl.dataset.transformer import *\n",
"from matplotlib.pyplot import imshow\n",
"from pyspark import SparkContext\n",
"sc=SparkContext.getOrCreate(conf=create_spark_conf().setMaster(\"local[4]\").set(\"spark.driver.memory\",\"2g\"))\n",
"\n",
"init_engine()"
]
Expand Down Expand Up @@ -166,15 +173,15 @@
"text": [
"predict predict: \n",
"\n",
"[ 1.48450136]\n",
"[ 2.33639312]\n",
"\n",
"[ 3.27808809]\n",
"[ 2.0999496]\n",
"\n",
"[ 1.87193513]\n",
"[ 1.83889556]\n",
"\n",
"[ 3.40717745]\n",
"[ 1.95105672]\n",
"\n",
"[ 4.11920691]\n",
"[ 2.58288598]\n",
"\n"
]
}
Expand Down Expand Up @@ -205,7 +212,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"8.19934\n"
"8.20632\n"
]
}
],
Expand Down
Loading

0 comments on commit 8478159

Please sign in to comment.