Skip to content

Commit 4dcc44f

Browse files
committedMay 9, 2020
.
1 parent 2f9c9ea commit 4dcc44f

File tree

4 files changed

+78
-38
lines changed

4 files changed

+78
-38
lines changed
 

‎docker.rst

+33-18
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ Note that Dockerhub can only allow a single image to be made private for the fre
128128
Docker Compose
129129
----------------
130130

131-
In a production environment, a docker compose file can be used to run all separate docker containers (which interact with each other)
131+
In a production environment, a docker compose file can be used to run all separate docker containers
132132
together. It consists of all necessary configurations that a ``docker run`` command provides in a yaml file.
133133

134134
So, instead of entering multiple ``docker run imageX``, we can just run one docker compose file to start all images.
135+
We also input all the commands like ports, volumes, depends_on
135136

136137
.. figure:: images/docker_compose1.png
137138
:width: 650px
@@ -141,25 +142,33 @@ So, instead of entering multiple ``docker run imageX``, we can just run one dock
141142

142143
Below is an example using wordpress blog, where both the wordpress and mysql database are needed to get it working.
143144

145+
Run ``docker-compose up`` command to launch.
146+
If there are some images not built yet, we can add another specification in the docker compose file
147+
e.g., ``build: /directory_name``.
148+
144149
.. code:: python
145150
146-
# in ymal file, ":" represents dictionary
147-
# "-" represents list
148-
# note that spaces matter
149-
version: '3'
151+
# in ymal file,
152+
":" represents dictionary
153+
# "-" represents list
154+
$ the 2nd level definition, e.g. "web:" is just a name, can give it anything
155+
# note that spaces matter
156+
# must specify version
157+
158+
version: 3
150159
services:
151-
mysql:
152-
image: "mysql"
153-
environment:
154-
- MYSQL_ROOT_PASSWORD=password
155-
volumes:
156-
- "/data/mysql:/var/lib/mysql"
157-
web:
158-
image: "wordpress"
159-
ports:
160-
- "8080:80"
161-
environment:
162-
- WORDPRESS_DB_PASSWORD=password
160+
mysql:
161+
image: "mysql"
162+
environment:
163+
- MYSQL_ROOT_PASSWORD=password
164+
volumes:
165+
- "/data/mysql:/var/lib/mysql"
166+
web:
167+
image: "wordpress"
168+
ports:
169+
- "8080:80"
170+
environment:
171+
- WORDPRESS_DB_PASSWORD=password
163172
164173
165174
Docker Swarm
@@ -311,4 +320,10 @@ Commands
311320

312321
+--------------------------------------+------------------------------------+
313322
| ``docker exec container_nm COMMAND`` | execute a command within container |
314-
+--------------------------------------+------------------------------------+
323+
+--------------------------------------+------------------------------------+
324+
325+
326+
Tips
327+
*****
328+
329+
https://pythonspeed.com/articles/multi-stage-docker-python/

‎flask.rst

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FLASK
2+
======
3+
4+
Flask is a micro web framework written in Python.
5+
It is easy and fast to implement with the knowledge of basic web development and REST APIs.
6+
7+
8+
Basics
9+
------
10+
11+
.. code:: Python
12+
13+
from flask import Flask, render_template
14+
15+
app = Flask(__name__)
16+
17+
18+
@app.route('/')
19+
def index():
20+
return render_template('index.html')
21+
22+
if __name__ == '__main__':
23+
app.run(debug = True)
24+
25+
26+
Folder Structure
27+
-----------------
28+
29+
There are some default directory structure to adhere to.
30+
The first is that HTML files are placed under /templates,
31+
second is for css or other static files like images, will be placed under /static
32+
33+
```
34+
├── app.py
35+
├── static
36+
│   └── img
37+
│   └── image.png
38+
└── templates
39+
└── index.html
40+
```

‎index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ A lot of the content are compiled from various resources, so please cite them ap
2929
evaluation
3030
explainability
3131
utils
32+
flask
3233
docker
3334
ethics
3435
resources

‎sl-deeplearning.rst

+4-20
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ architecture includes **LeNet-5** (handwriting recognition), **AlexNet** (deeper
497497

498498
.. _article1: https://medium.com/@RaghavPrabhu/cnn-architectures-lenet-alexnet-vgg-googlenet-and-resnet-7c81c017b848
499499

500-
501500
Keras Model
502501
***************
503502

@@ -509,24 +508,10 @@ Keras Model
509508
from tensorflow.keras.layers import Dense, Dropout, Conv2D, MaxPooling2D, Flatten
510509
from tensorflow.keras.optimizers import RMSprop
511510
512-
(X_train, y_train), (X_test, y_test) = mnist.load_data()
513-
514-
515-
# need to reshape image dataset
516-
total_rows_train = X_train.shape[0]
517-
total_rows_test = X_test.shape[0]
518-
sample_rows = X_train.shape[1]
519-
sample_columns = X_train.shape[2]
520-
num_channels = 1
521-
522-
# i.e. X_train = X_train.reshape(60000,28,28,1), where 1 means images are grayscale
523-
X_train = X_train.reshape(total_rows_train,sample_rows,sample_columns,num_channels)
524-
X_test = X_test.reshape(total_rows_test,sample_rows,sample_columns,num_channels)
525-
526-
527511
model = Sequential()
528-
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu',
529-
input_shape=(sample_rows, sample_columns, num_channels)))
512+
model.add(Conv2D(32, kernel_size=(3, 3),
513+
activation='relu',
514+
input_shape=input_shape))
530515
531516
# 64 3x3 kernels
532517
model.add(Conv2D(64, (3, 3), activation='relu'))
@@ -543,7 +528,6 @@ Keras Model
543528
# Final categorization from 0-9 with softmax
544529
model.add(Dense(10, activation='softmax'))
545530
546-
547531
model.summary()
548532
549533
# _________________________________________________________________
@@ -570,7 +554,7 @@ Keras Model
570554
# Non-trainable params: 0
571555
# _________________________________________________________________
572556
573-
model.compile(loss='sparse_categorical_crossentropy',
557+
model.compile(loss='categorical_crossentropy',
574558
optimizer='adam',
575559
metrics=['accuracy'])
576560

0 commit comments

Comments
 (0)