diff --git a/doc/pub/week41/html/._week41-bs028.html b/doc/pub/week41/html/._week41-bs028.html index c333dd65e..f40af878d 100644 --- a/doc/pub/week41/html/._week41-bs028.html +++ b/doc/pub/week41/html/._week41-bs028.html @@ -258,7 +258,6 @@ MathJax.Hub.Config({
Keras is a high level neural network that supports Tensorflow, CTNK and Theano as backends. -If you have Tensorflow installed Keras is available through the tf.keras module. If you have Anaconda installed you may run the following command
@@ -266,15 +265,10 @@ If you have Anaconda installed you may run the following command
conda install keras
-Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager: +You can look up the instructions here for more information.
- - -
pip install keras
--or look up the instructions here. +We will to a large extent use keras in this course.
diff --git a/doc/pub/week41/html/._week41-bs029.html b/doc/pub/week41/html/._week41-bs029.html index f9bfbf306..b3d7c3e88 100644 --- a/doc/pub/week41/html/._week41-bs029.html +++ b/doc/pub/week41/html/._week41-bs029.html @@ -255,6 +255,9 @@ MathJax.Hub.Config({
+Let us look again at the MINST data set. +
@@ -326,7 +329,14 @@ X_train, X_test, Y_train, Y_test = train_tes
-
def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
+epochs = 100
+batch_size = 100
+n_neurons_layer1 = 100
+n_neurons_layer2 = 50
+n_categories = 10
+eta_vals = np.logspace(-5, 1, 7)
+lmbd_vals = np.logspace(-5, 1, 7)
+def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
model = Sequential()
model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
diff --git a/doc/pub/week41/html/._week41-bs057.html b/doc/pub/week41/html/._week41-bs057.html
index 842615fcd..330870843 100644
--- a/doc/pub/week41/html/._week41-bs057.html
+++ b/doc/pub/week41/html/._week41-bs057.html
@@ -257,7 +257,16 @@ MathJax.Hub.Config({
-
from keras.utils import to_categorical
+from tensorflow.keras.layers import Input
+from tensorflow.keras.models import Sequential #This allows appending layers to existing models
+from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer
+from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)
+from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)
+from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function
+from tensorflow.keras import Conv2D
+from tensorflow.keras import MaxPooling2D
+from tensorflow.keras import Flatten
+
from sklearn.model_selection import train_test_split
# representation of labels
diff --git a/doc/pub/week41/html/._week41-bs058.html b/doc/pub/week41/html/._week41-bs058.html
index bed3fbe8d..b639fd7ad 100644
--- a/doc/pub/week41/html/._week41-bs058.html
+++ b/doc/pub/week41/html/._week41-bs058.html
@@ -258,15 +258,7 @@ MathJax.Hub.Config({
-
from keras.models import Sequential
-from keras.layers.convolutional import Conv2D
-from keras.layers.convolutional import MaxPooling2D
-from keras.layers import Flatten
-from keras.layers import Dense
-from keras.regularizers import l2
-from keras.optimizers import SGD
-
-def create_convolutional_neural_network_keras(input_shape, receptive_field,
+def create_convolutional_neural_network_keras(input_shape, receptive_field,
n_filters, n_neurons_connected, n_categories,
eta, lmbd):
model = Sequential()
diff --git a/doc/pub/week41/html/week41-reveal.html b/doc/pub/week41/html/week41-reveal.html
index 7bb99a7c6..0d5daa439 100644
--- a/doc/pub/week41/html/week41-reveal.html
+++ b/doc/pub/week41/html/week41-reveal.html
@@ -1534,7 +1534,6 @@ conda activate tf-gpu
Keras is a high level neural network
that supports Tensorflow, CTNK and Theano as backends.
-If you have Tensorflow installed Keras is available through the tf.keras module.
If you have Anaconda installed you may run the following command
@@ -1542,21 +1541,19 @@ If you have Anaconda installed you may run the following command
conda install keras
-Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager:
+You can look up the instructions here for more information.
-
-
-
pip install keras
-
-
-or look up the instructions here.
+We will to a large extent use keras in this course.
Collect and pre-process data
+
+Let us look again at the MINST data set.
+
@@ -1628,7 +1625,14 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
-
def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
+epochs = 100
+batch_size = 100
+n_neurons_layer1 = 100
+n_neurons_layer2 = 50
+n_categories = 10
+eta_vals = np.logspace(-5, 1, 7)
+lmbd_vals = np.logspace(-5, 1, 7)
+def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
model = Sequential()
model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
@@ -2533,7 +2537,16 @@ plt.show()
-
from keras.utils import to_categorical
+from tensorflow.keras.layers import Input
+from tensorflow.keras.models import Sequential #This allows appending layers to existing models
+from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer
+from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)
+from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)
+from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function
+from tensorflow.keras import Conv2D
+from tensorflow.keras import MaxPooling2D
+from tensorflow.keras import Flatten
+
from sklearn.model_selection import train_test_split
# representation of labels
@@ -2555,15 +2568,7 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
-
from keras.models import Sequential
-from keras.layers.convolutional import Conv2D
-from keras.layers.convolutional import MaxPooling2D
-from keras.layers import Flatten
-from keras.layers import Dense
-from keras.regularizers import l2
-from keras.optimizers import SGD
-
-def create_convolutional_neural_network_keras(input_shape, receptive_field,
+def create_convolutional_neural_network_keras(input_shape, receptive_field,
n_filters, n_neurons_connected, n_categories,
eta, lmbd):
model = Sequential()
diff --git a/doc/pub/week41/html/week41-solarized.html b/doc/pub/week41/html/week41-solarized.html
index b0f026995..7e0d7b463 100644
--- a/doc/pub/week41/html/week41-solarized.html
+++ b/doc/pub/week41/html/week41-solarized.html
@@ -1463,7 +1463,6 @@ conda activate tf-gpu
Keras is a high level neural network
that supports Tensorflow, CTNK and Theano as backends.
-If you have Tensorflow installed Keras is available through the tf.keras module.
If you have Anaconda installed you may run the following command
@@ -1471,21 +1470,19 @@ If you have Anaconda installed you may run the following command
conda install keras
-Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager:
+You can look up the instructions here for more information.
-
-
-
pip install keras
-
-
-or look up the instructions here.
+We will to a large extent use keras in this course.
Collect and pre-process data
+
+Let us look again at the MINST data set.
+
@@ -1557,7 +1554,14 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
-
def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
+epochs = 100
+batch_size = 100
+n_neurons_layer1 = 100
+n_neurons_layer2 = 50
+n_categories = 10
+eta_vals = np.logspace(-5, 1, 7)
+lmbd_vals = np.logspace(-5, 1, 7)
+def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
model = Sequential()
model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
@@ -2447,7 +2451,16 @@ plt.show()
-
from keras.utils import to_categorical
+from tensorflow.keras.layers import Input
+from tensorflow.keras.models import Sequential #This allows appending layers to existing models
+from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer
+from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)
+from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)
+from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function
+from tensorflow.keras import Conv2D
+from tensorflow.keras import MaxPooling2D
+from tensorflow.keras import Flatten
+
from sklearn.model_selection import train_test_split
# representation of labels
@@ -2468,15 +2481,7 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
-
from keras.models import Sequential
-from keras.layers.convolutional import Conv2D
-from keras.layers.convolutional import MaxPooling2D
-from keras.layers import Flatten
-from keras.layers import Dense
-from keras.regularizers import l2
-from keras.optimizers import SGD
-
-def create_convolutional_neural_network_keras(input_shape, receptive_field,
+def create_convolutional_neural_network_keras(input_shape, receptive_field,
n_filters, n_neurons_connected, n_categories,
eta, lmbd):
model = Sequential()
diff --git a/doc/pub/week41/html/week41.html b/doc/pub/week41/html/week41.html
index 5345112de..bf88efb09 100644
--- a/doc/pub/week41/html/week41.html
+++ b/doc/pub/week41/html/week41.html
@@ -1468,7 +1468,6 @@ conda activate tf-gpu
Keras is a high level neural network
that supports Tensorflow, CTNK and Theano as backends.
-If you have Tensorflow installed Keras is available through the tf.keras module.
If you have Anaconda installed you may run the following command
@@ -1476,21 +1475,19 @@ If you have Anaconda installed you may run the following command
conda install keras
-Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager:
+You can look up the instructions here for more information.
-
-
-
pip install keras
-
-
-or look up the instructions here.
+We will to a large extent use keras in this course.
Collect and pre-process data
+
+Let us look again at the MINST data set.
+
@@ -1562,7 +1559,14 @@ X_train, X_test, Y_train, Y_test = train_tes
-
def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
+epochs = 100
+batch_size = 100
+n_neurons_layer1 = 100
+n_neurons_layer2 = 50
+n_categories = 10
+eta_vals = np.logspace(-5, 1, 7)
+lmbd_vals = np.logspace(-5, 1, 7)
+def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
model = Sequential()
model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
@@ -2452,7 +2456,16 @@ plt.show()
-
from keras.utils import to_categorical
+from tensorflow.keras.layers import Input
+from tensorflow.keras.models import Sequential #This allows appending layers to existing models
+from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer
+from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)
+from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)
+from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function
+from tensorflow.keras import Conv2D
+from tensorflow.keras import MaxPooling2D
+from tensorflow.keras import Flatten
+
from sklearn.model_selection import train_test_split
# representation of labels
@@ -2473,15 +2486,7 @@ X_train, X_test, Y_train, Y_test = train_tes
-
from keras.models import Sequential
-from keras.layers.convolutional import Conv2D
-from keras.layers.convolutional import MaxPooling2D
-from keras.layers import Flatten
-from keras.layers import Dense
-from keras.regularizers import l2
-from keras.optimizers import SGD
-
-def create_convolutional_neural_network_keras(input_shape, receptive_field,
+def create_convolutional_neural_network_keras(input_shape, receptive_field,
n_filters, n_neurons_connected, n_categories,
eta, lmbd):
model = Sequential()
diff --git a/doc/pub/week41/ipynb/ipynb-week41-src.tar.gz b/doc/pub/week41/ipynb/ipynb-week41-src.tar.gz
index b7f9e9bde..1fae036bf 100644
Binary files a/doc/pub/week41/ipynb/ipynb-week41-src.tar.gz and b/doc/pub/week41/ipynb/ipynb-week41-src.tar.gz differ
diff --git a/doc/pub/week41/ipynb/week41.ipynb b/doc/pub/week41/ipynb/week41.ipynb
index 1e0483f08..43b741032 100644
--- a/doc/pub/week41/ipynb/week41.ipynb
+++ b/doc/pub/week41/ipynb/week41.ipynb
@@ -1465,7 +1465,6 @@
"\n",
"Keras is a high level [neural network](https://en.wikipedia.org/wiki/Application_programming_interface)\n",
"that supports Tensorflow, CTNK and Theano as backends. \n",
- "If you have Tensorflow installed Keras is available through the *tf.keras* module. \n",
"If you have Anaconda installed you may run the following command"
]
},
@@ -1484,7 +1483,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager:"
+ "You can look up the [instructions here](https://keras.io/) for more information.\n",
+ "\n",
+ "We will to a large extent use **keras** in this course. \n",
+ "\n",
+ "## Collect and pre-process data\n",
+ "\n",
+ "Let us look again at the MINST data set."
]
},
{
@@ -1494,27 +1499,6 @@
"collapsed": false
},
"outputs": [],
- "source": [
- "pip install keras"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "or look up the [instructions here](https://keras.io/).\n",
- "\n",
- "\n",
- "## Collect and pre-process data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
"source": [
"# import necessary packages\n",
"import numpy as np\n",
@@ -1563,7 +1547,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 17,
"metadata": {
"collapsed": false
},
@@ -1590,13 +1574,20 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"\n",
+ "epochs = 100\n",
+ "batch_size = 100\n",
+ "n_neurons_layer1 = 100\n",
+ "n_neurons_layer2 = 50\n",
+ "n_categories = 10\n",
+ "eta_vals = np.logspace(-5, 1, 7)\n",
+ "lmbd_vals = np.logspace(-5, 1, 7)\n",
"def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):\n",
" model = Sequential()\n",
" model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))\n",
@@ -1611,7 +1602,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 19,
"metadata": {
"collapsed": false
},
@@ -1636,7 +1627,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 20,
"metadata": {
"collapsed": false
},
@@ -1684,7 +1675,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 21,
"metadata": {
"collapsed": false
},
@@ -2400,7 +2391,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 22,
"metadata": {
"collapsed": false
},
@@ -2457,13 +2448,22 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
- "from keras.utils import to_categorical\n",
+ "from tensorflow.keras.layers import Input\n",
+ "from tensorflow.keras.models import Sequential #This allows appending layers to existing models\n",
+ "from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer\n",
+ "from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)\n",
+ "from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)\n",
+ "from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function\n",
+ "from tensorflow.keras import Conv2D\n",
+ "from tensorflow.keras import MaxPooling2D\n",
+ "from tensorflow.keras import Flatten\n",
+ "\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"# representation of labels\n",
@@ -2487,19 +2487,13 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
- "from keras.models import Sequential\n",
- "from keras.layers.convolutional import Conv2D\n",
- "from keras.layers.convolutional import MaxPooling2D\n",
- "from keras.layers import Flatten\n",
- "from keras.layers import Dense\n",
- "from keras.regularizers import l2\n",
- "from keras.optimizers import SGD\n",
+ "\n",
"\n",
"def create_convolutional_neural_network_keras(input_shape, receptive_field,\n",
" n_filters, n_neurons_connected, n_categories,\n",
@@ -2538,7 +2532,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 25,
"metadata": {
"collapsed": false
},
diff --git a/doc/src/week41/week41.do.txt b/doc/src/week41/week41.do.txt
index 026c7ba06..7cb4a956c 100644
--- a/doc/src/week41/week41.do.txt
+++ b/doc/src/week41/week41.do.txt
@@ -1116,23 +1116,19 @@ conda activate tf-gpu
Keras is a high level "neural network":"https://en.wikipedia.org/wiki/Application_programming_interface"
that supports Tensorflow, CTNK and Theano as backends.
-If you have Tensorflow installed Keras is available through the *tf.keras* module.
If you have Anaconda installed you may run the following command
!bc pycod
conda install keras
!ec
-
-Alternatively, if you have Tensorflow or one of the other supported backends install you may use the pip package manager:
-
-!bc pycod
-pip install keras
-!ec
-or look up the "instructions here":"https://keras.io/".
+You can look up the "instructions here":"https://keras.io/" for more information.
+We will to a large extent use _keras_ in this course.
!split
===== Collect and pre-process data =====
+Let us look again at the MINST data set.
+
!bc pycod
# import necessary packages
import numpy as np
@@ -1203,6 +1199,13 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
!bc pycod
+epochs = 100
+batch_size = 100
+n_neurons_layer1 = 100
+n_neurons_layer2 = 50
+n_categories = 10
+eta_vals = np.logspace(-5, 1, 7)
+lmbd_vals = np.logspace(-5, 1, 7)
def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):
model = Sequential()
model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))
@@ -2005,7 +2008,16 @@ plt.show()
!split
===== Importing Keras and Tensorflow =====
!bc pycod
-from keras.utils import to_categorical
+from tensorflow.keras.layers import Input
+from tensorflow.keras.models import Sequential #This allows appending layers to existing models
+from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer
+from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)
+from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)
+from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function
+from tensorflow.keras import Conv2D
+from tensorflow.keras import MaxPooling2D
+from tensorflow.keras import Flatten
+
from sklearn.model_selection import train_test_split
# representation of labels
@@ -2023,13 +2035,7 @@ X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=t
===== Running with Keras =====
!bc pycod
-from keras.models import Sequential
-from keras.layers.convolutional import Conv2D
-from keras.layers.convolutional import MaxPooling2D
-from keras.layers import Flatten
-from keras.layers import Dense
-from keras.regularizers import l2
-from keras.optimizers import SGD
+
def create_convolutional_neural_network_keras(input_shape, receptive_field,
n_filters, n_neurons_connected, n_categories,