├── Chapter-1
├── lesson-1-workbook.html
└── lesson-1-workbook.ipynb
├── Chapter-2
├── lesson-2-workbook.html
└── lesson-2-workbook.ipynb
├── Chapter-3
├── lesson-3-workbook.html
└── lesson-3-workbook.ipynb
├── Chapter-4
├── activity_1
│ ├── requirements.txt
│ └── test_stack.py
└── activity_2
│ ├── LICENSE
│ ├── data.zip
│ ├── mnist.py
│ ├── mnist_example
│ ├── MNIST-model.zip
│ ├── checkpoint
│ ├── data.zip
│ ├── model.ckpt-0.index
│ ├── model.ckpt-0.meta
│ ├── model.ckpt-1000.index
│ ├── model.ckpt-1000.meta
│ ├── model.ckpt-1500.index
│ ├── model.ckpt-1500.meta
│ ├── model.ckpt-2000.index
│ ├── model.ckpt-2000.meta
│ ├── model.ckpt-500.index
│ └── model.ckpt-500.meta
│ └── requirements.txt
├── Chapter-5
├── activity_3.zip
├── activity_4.zip
└── activity_5.zip
├── Chapter-6
├── activity_6.zip
└── activity_7.zip
├── Chapter-7
├── activity_8.zip
└── activity_9.zip
├── LICENSE
├── README.md
└── data
├── countries
├── interest-rates.csv
├── merged.csv
└── populations.csv
└── hr-analytics
├── hr_data.csv
└── hr_data_processed.csv
/Chapter-4/activity_1/requirements.txt:
--------------------------------------------------------------------------------
1 | appnope==0.1.0
2 | beautifulsoup4==4.6.0
3 | bleach==1.5.0
4 | certifi==2017.11.5
5 | chardet==3.0.4
6 | click==6.7
7 | colorama==0.3.9
8 | coverage==4.4.2
9 | cycler==0.10.0
10 | decorator==4.1.2
11 | entrypoints==0.2.3
12 | enum34==1.1.6
13 | Flask==0.12.2
14 | Flask-API==1.0
15 | Flask-Caching==1.3.3
16 | Flask-Cors==3.0.3
17 | Flask-Testing==0.7.1
18 | graphviz==0.8.1
19 | h5py==2.7.1
20 | html5lib==0.9999999
21 | idna==2.6
22 | ipykernel==4.7.0
23 | ipython==6.2.1
24 | ipython-genutils==0.2.0
25 | ipywidgets==7.0.5
26 | itsdangerous==0.24
27 | jedi==0.11.1
28 | Jinja2==2.10
29 | jsonschema==2.6.0
30 | jupyter==1.0.0
31 | jupyter-client==5.1.0
32 | jupyter-console==5.2.0
33 | jupyter-core==4.4.0
34 | Keras==2.1.2
35 | lesscpy==0.12.0
36 | lxml==4.1.1
37 | Markdown==2.6.10
38 | MarkupSafe==1.0
39 | matplotlib==2.1.0
40 | mistune==0.8.3
41 | nbconvert==5.3.1
42 | nbformat==4.4.0
43 | nose==1.3.7
44 | notebook==5.2.2
45 | numpy==1.13.3
46 | pandas==0.21.1
47 | pandocfilters==1.4.2
48 | parso==0.1.1
49 | pexpect==4.3.1
50 | pickleshare==0.7.4
51 | ply==3.10
52 | prompt-toolkit==1.0.15
53 | protobuf==3.5.0.post1
54 | ptyprocess==0.5.2
55 | pydot==1.2.3
56 | Pygments==2.2.0
57 | pyparsing==2.2.0
58 | python-dateutil==2.6.1
59 | pytz==2017.3
60 | PyYAML==3.12
61 | pyzmq==16.0.3
62 | qtconsole==4.3.1
63 | redis==2.10.6
64 | rednose==1.2.3
65 | requests==2.18.4
66 | scipy==1.0.0
67 | seaborn==0.8.1
68 | simplegeneric==0.8.1
69 | six==1.11.0
70 | tensorflow==1.4.0
71 | tensorflow-tensorboard==0.4.0rc3
72 | terminado==0.8.1
73 | termstyle==0.1.11
74 | testpath==0.3.1
75 | tornado==4.5.2
76 | tqdm==4.19.4
77 | traitlets==4.3.2
78 | urllib3==1.22
79 | wcwidth==0.1.7
80 | Werkzeug==0.13
81 | widgetsnbextension==3.0.8
82 |
--------------------------------------------------------------------------------
/Chapter-4/activity_1/test_stack.py:
--------------------------------------------------------------------------------
1 | """
2 | Simple tests for verifying software requirements.
3 | These tests will check if the following conditions
4 | are met:
5 |
6 | * Python is 3.0 or higher.
7 | * TensorFlow is 1.4 or higher.
8 | * Keras is 2.0 or higher.
9 |
10 | The program returns helpful error messages if
11 | the conditions above are not met.abs
12 |
13 | Proceed to Lesson 2 when all tests pass.
14 |
15 | --
16 | Author: Luis Capelo
17 | Date: October 17, 2017
18 | """
19 | import sys
20 |
21 |
22 | def __separator(c):
23 | """
24 | Prints a pretty separator.
25 |
26 | Parameters
27 | ----------
28 | c: str
29 | Character to use.
30 | """
31 | print(c * 65)
32 |
33 | def test_python():
34 | """
35 | Tests if Python 3 is installed.
36 | """
37 | message = None
38 | if sys.version_info[0] == 3:
39 | success = True
40 | log = """
41 | PASS: Python 3.0 (or higher) is installed.
42 | """
43 |
44 | else:
45 | success = False
46 | log = """
47 | FAIL: Python 3.0 (or higher) not detected.
48 | """
49 | message = """
50 | Please install it before proceeding.
51 | Follow instructions in the official Python
52 | website in order to install it in your platform:
53 |
54 | https://www.python.org/downloads/
55 | """
56 |
57 | print(log)
58 | if message:
59 | print(message)
60 |
61 | __separator('~')
62 | return success
63 |
64 | def test_tensorflow():
65 | """
66 | Tests if TensorFlow is installed.
67 | """
68 | message = None
69 | try:
70 | import tensorflow
71 |
72 | if tensorflow.__version__ >= '1.4.0':
73 | success = True
74 | log = """
75 | PASS: TensorFlow 1.4.0 (or higher) is installed.
76 | """
77 |
78 | else:
79 | success = False
80 | log = """
81 | FAIL: TensorFlow 1.4.0 (or higher) not detected.
82 | """
83 | message = """
84 | Please install it before proceeding.
85 | Follow instructions in the official TensorFlow
86 | website in order to install it in your platform:
87 |
88 | https://www.tensorflow.org/install/
89 | """
90 |
91 | except ModuleNotFoundError:
92 | success = False
93 | log = """
94 | FAIL: TensorFlow 1.4.0 (or higher) not detected.
95 | """
96 | message = """
97 | Please install it before proceeding.
98 | Follow instructions in the official TensorFlow
99 | website in order to install it in your platform:
100 |
101 | https://www.tensorflow.org/install/
102 | """
103 |
104 | print(log)
105 | if message:
106 | print(message)
107 |
108 | __separator('~')
109 | return success
110 |
111 | def test_keras():
112 | """
113 | Tests if Keras is installed.
114 | """
115 | message = None
116 | try:
117 | import keras
118 |
119 | if sys.version_info[0] == 3:
120 | success = True
121 | log = """
122 | PASS: Keras 2.0 (or higher) is installed.
123 | """
124 |
125 | else:
126 | success = False
127 | log = """
128 | FAIL: Keras 2.0 (or higher) not detected.
129 | """
130 | message = """
131 | Please install it before proceeding.
132 | Follow instructions in the official Keras
133 | website in order to install it in your platform:
134 |
135 | https://keras.io/#installation
136 | """
137 |
138 | except ModuleNotFoundError:
139 | success = False
140 | log = """
141 | FAIL: Keras 2.0 (or higher) not detected.
142 | """
143 | message = """
144 | Please install it before proceeding.
145 | Follow instructions in the official Keras
146 | website in order to install it in your platform:
147 |
148 | https://keras.io/#installation
149 | """
150 |
151 | print(log)
152 | if message:
153 | print(message)
154 |
155 | __separator('~')
156 | return success
157 |
158 |
159 | if __name__ == '__main__':
160 | __separator('=')
161 | test_results = [
162 | test_python(),
163 | test_tensorflow(),
164 | test_keras()]
165 |
166 | if False in test_results:
167 | print(
168 | """
169 | ** Please review software requirements before
170 | ** proceeding to Lesson 2.
171 | """
172 | )
173 | else:
174 | print(
175 | """
176 | ** Python, TensorFlow, and Keras are available.
177 | """
178 | )
179 | __separator('=')
180 |
--------------------------------------------------------------------------------
/Chapter-4/activity_2/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017 Google, Inc.
2 |
3 | Apache License
4 | Version 2.0, January 2004
5 | http://www.apache.org/licenses/
6 |
7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8 |
9 | 1. Definitions.
10 |
11 | "License" shall mean the terms and conditions for use, reproduction,
12 | and distribution as defined by Sections 1 through 9 of this document.
13 |
14 | "Licensor" shall mean the copyright owner or entity authorized by
15 | the copyright owner that is granting the License.
16 |
17 | "Legal Entity" shall mean the union of the acting entity and all
18 | other entities that control, are controlled by, or are under common
19 | control with that entity. For the purposes of this definition,
20 | "control" means (i) the power, direct or indirect, to cause the
21 | direction or management of such entity, whether by contract or
22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
23 | outstanding shares, or (iii) beneficial ownership of such entity.
24 |
25 | "You" (or "Your") shall mean an individual or Legal Entity
26 | exercising permissions granted by this License.
27 |
28 | "Source" form shall mean the preferred form for making modifications,
29 | including but not limited to software source code, documentation
30 | source, and configuration files.
31 |
32 | "Object" form shall mean any form resulting from mechanical
33 | transformation or translation of a Source form, including but
34 | not limited to compiled object code, generated documentation,
35 | and conversions to other media types.
36 |
37 | "Work" shall mean the work of authorship, whether in Source or
38 | Object form, made available under the License, as indicated by a
39 | copyright notice that is included in or attached to the work
40 | (an example is provided in the Appendix below).
41 |
42 | "Derivative Works" shall mean any work, whether in Source or Object
43 | form, that is based on (or derived from) the Work and for which the
44 | editorial revisions, annotations, elaborations, or other modifications
45 | represent, as a whole, an original work of authorship. For the purposes
46 | of this License, Derivative Works shall not include works that remain
47 | separable from, or merely link (or bind by name) to the interfaces of,
48 | the Work and Derivative Works thereof.
49 |
50 | "Contribution" shall mean any work of authorship, including
51 | the original version of the Work and any modifications or additions
52 | to that Work or Derivative Works thereof, that is intentionally
53 | submitted to Licensor for inclusion in the Work by the copyright owner
54 | or by an individual or Legal Entity authorized to submit on behalf of
55 | the copyright owner. For the purposes of this definition, "submitted"
56 | means any form of electronic, verbal, or written communication sent
57 | to the Licensor or its representatives, including but not limited to
58 | communication on electronic mailing lists, source code control systems,
59 | and issue tracking systems that are managed by, or on behalf of, the
60 | Licensor for the purpose of discussing and improving the Work, but
61 | excluding communication that is conspicuously marked or otherwise
62 | designated in writing by the copyright owner as "Not a Contribution."
63 |
64 | "Contributor" shall mean Licensor and any individual or Legal Entity
65 | on behalf of whom a Contribution has been received by Licensor and
66 | subsequently incorporated within the Work.
67 |
68 | 2. Grant of Copyright License. Subject to the terms and conditions of
69 | this License, each Contributor hereby grants to You a perpetual,
70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71 | copyright license to reproduce, prepare Derivative Works of,
72 | publicly display, publicly perform, sublicense, and distribute the
73 | Work and such Derivative Works in Source or Object form.
74 |
75 | 3. Grant of Patent License. Subject to the terms and conditions of
76 | this License, each Contributor hereby grants to You a perpetual,
77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78 | (except as stated in this section) patent license to make, have made,
79 | use, offer to sell, sell, import, and otherwise transfer the Work,
80 | where such license applies only to those patent claims licensable
81 | by such Contributor that are necessarily infringed by their
82 | Contribution(s) alone or by combination of their Contribution(s)
83 | with the Work to which such Contribution(s) was submitted. If You
84 | institute patent litigation against any entity (including a
85 | cross-claim or counterclaim in a lawsuit) alleging that the Work
86 | or a Contribution incorporated within the Work constitutes direct
87 | or contributory patent infringement, then any patent licenses
88 | granted to You under this License for that Work shall terminate
89 | as of the date such litigation is filed.
90 |
91 | 4. Redistribution. You may reproduce and distribute copies of the
92 | Work or Derivative Works thereof in any medium, with or without
93 | modifications, and in Source or Object form, provided that You
94 | meet the following conditions:
95 |
96 | (a) You must give any other recipients of the Work or
97 | Derivative Works a copy of this License; and
98 |
99 | (b) You must cause any modified files to carry prominent notices
100 | stating that You changed the files; and
101 |
102 | (c) You must retain, in the Source form of any Derivative Works
103 | that You distribute, all copyright, patent, trademark, and
104 | attribution notices from the Source form of the Work,
105 | excluding those notices that do not pertain to any part of
106 | the Derivative Works; and
107 |
108 | (d) If the Work includes a "NOTICE" text file as part of its
109 | distribution, then any Derivative Works that You distribute must
110 | include a readable copy of the attribution notices contained
111 | within such NOTICE file, excluding those notices that do not
112 | pertain to any part of the Derivative Works, in at least one
113 | of the following places: within a NOTICE text file distributed
114 | as part of the Derivative Works; within the Source form or
115 | documentation, if provided along with the Derivative Works; or,
116 | within a display generated by the Derivative Works, if and
117 | wherever such third-party notices normally appear. The contents
118 | of the NOTICE file are for informational purposes only and
119 | do not modify the License. You may add Your own attribution
120 | notices within Derivative Works that You distribute, alongside
121 | or as an addendum to the NOTICE text from the Work, provided
122 | that such additional attribution notices cannot be construed
123 | as modifying the License.
124 |
125 | You may add Your own copyright statement to Your modifications and
126 | may provide additional or different license terms and conditions
127 | for use, reproduction, or distribution of Your modifications, or
128 | for any such Derivative Works as a whole, provided Your use,
129 | reproduction, and distribution of the Work otherwise complies with
130 | the conditions stated in this License.
131 |
132 | 5. Submission of Contributions. Unless You explicitly state otherwise,
133 | any Contribution intentionally submitted for inclusion in the Work
134 | by You to the Licensor shall be under the terms and conditions of
135 | this License, without any additional terms or conditions.
136 | Notwithstanding the above, nothing herein shall supersede or modify
137 | the terms of any separate license agreement you may have executed
138 | with Licensor regarding such Contributions.
139 |
140 | 6. Trademarks. This License does not grant permission to use the trade
141 | names, trademarks, service marks, or product names of the Licensor,
142 | except as required for reasonable and customary use in describing the
143 | origin of the Work and reproducing the content of the NOTICE file.
144 |
145 | 7. Disclaimer of Warranty. Unless required by applicable law or
146 | agreed to in writing, Licensor provides the Work (and each
147 | Contributor provides its Contributions) on an "AS IS" BASIS,
148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149 | implied, including, without limitation, any warranties or conditions
150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151 | PARTICULAR PURPOSE. You are solely responsible for determining the
152 | appropriateness of using or redistributing the Work and assume any
153 | risks associated with Your exercise of permissions under this License.
154 |
155 | 8. Limitation of Liability. In no event and under no legal theory,
156 | whether in tort (including negligence), contract, or otherwise,
157 | unless required by applicable law (such as deliberate and grossly
158 | negligent acts) or agreed to in writing, shall any Contributor be
159 | liable to You for damages, including any direct, indirect, special,
160 | incidental, or consequential damages of any character arising as a
161 | result of this License or out of the use or inability to use the
162 | Work (including but not limited to damages for loss of goodwill,
163 | work stoppage, computer failure or malfunction, or any and all
164 | other commercial damages or losses), even if such Contributor
165 | has been advised of the possibility of such damages.
166 |
167 | 9. Accepting Warranty or Additional Liability. While redistributing
168 | the Work or Derivative Works thereof, You may choose to offer,
169 | and charge a fee for, acceptance of support, warranty, indemnity,
170 | or other liability obligations and/or rights consistent with this
171 | License. However, in accepting such obligations, You may act only
172 | on Your own behalf and on Your sole responsibility, not on behalf
173 | of any other Contributor, and only if You agree to indemnify,
174 | defend, and hold each Contributor harmless for any liability
175 | incurred by, or claims asserted against, such Contributor by reason
176 | of your accepting any such warranty or additional liability.
177 |
178 | END OF TERMS AND CONDITIONS
179 |
180 | APPENDIX: How to apply the Apache License to your work.
181 |
182 | To apply the Apache License to your work, attach the following
183 | boilerplate notice, with the fields enclosed by brackets "[]"
184 | replaced with your own identifying information. (Don't include
185 | the brackets!) The text should be enclosed in the appropriate
186 | comment syntax for the file format. We also recommend that a
187 | file or class name and description of purpose be included on the
188 | same "printed page" as the copyright notice for easier
189 | identification within third-party archives.
190 |
191 | Copyright 2017, Google, Inc.
192 |
193 | Licensed under the Apache License, Version 2.0 (the "License");
194 | you may not use this file except in compliance with the License.
195 | You may obtain a copy of the License at
196 |
197 | http://www.apache.org/licenses/LICENSE-2.0
198 |
199 | Unless required by applicable law or agreed to in writing, software
200 | distributed under the License is distributed on an "AS IS" BASIS,
201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202 | See the License for the specific language governing permissions and
203 | limitations under the License.
--------------------------------------------------------------------------------
/Chapter-4/activity_2/data.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/data.zip
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist.py:
--------------------------------------------------------------------------------
1 | """
2 |
3 | Copyright 2017 Google, Inc. All Rights Reserved.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | ----
18 | Original script can be found at
19 |
20 | https://github.com/dandelionmane/tf-dev-summit-tensorboard-tutorial
21 |
22 | And is similar to the TensorFlow tutorial script found at
23 |
24 | https://www.tensorflow.org/get_started/mnist/mechanics
25 |
26 | ----
27 | Modifications by: Luis Capelo
28 | Date: October 16, 2017
29 |
30 | """
31 | import os
32 | os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
33 |
34 | import tqdm
35 | import shutil
36 | import tensorflow as tf
37 |
38 | #
39 | # Script variables. Change these and observe
40 | # how results change.
41 | #
42 | LEARNING_RATE = 0.0001
43 | EPOCHS = 2000
44 |
45 | #
46 | # Script constants. Here we pull data available
47 | # locally. The data contains both the sprites
48 | # and the labels from the original MNIST dataset.
49 | #
50 | LOGDIR = "mnist_example/"
51 | LABELS = os.path.join(os.getcwd(), "labels_1024.tsv")
52 | SPRITES = os.path.join(os.getcwd(), "sprite_1024.png")
53 |
54 |
55 | def load_data():
56 | """
57 | Loads data form the MNIST dataset
58 | into memory.
59 |
60 | Returns
61 | -------
62 | TensorFlow object with dataset.
63 | """
64 | if not (os.path.isfile(LABELS) and os.path.isfile(SPRITES)):
65 | raise ValueError("""
66 | Necessary data files were not found. Make sure the files
67 |
68 | * labels_1024.tsv
69 | * sprite_1024.png
70 |
71 | are available in the same location where you run this
72 | script.
73 | """)
74 |
75 | return tf.contrib.learn.datasets.mnist.read_data_sets(
76 | train_dir=LOGDIR + "data", one_hot=True)
77 |
78 |
79 | def convolutional_layer(input, size_in, size_out, name="convolutional"):
80 | """
81 | Convolutional layer. Here we create the weights and biases
82 | distributions. We also define the convolution and the activation
83 | function (ReLU). Finally, we create some histogram summaries
84 | useful for TensorBoard.
85 |
86 | Parameters
87 | ----------
88 | size_in, size_out: int or float
89 | Where to truncate the normal distribution.
90 |
91 | name: str
92 | Name to give the TensorFlow scope.
93 | """
94 | with tf.name_scope(name):
95 |
96 | W = tf.Variable(tf.truncated_normal([5, 5, size_in, size_out], stddev=0.1), name="Weights")
97 | B = tf.Variable(tf.constant(0.1, shape=[size_out]), name="Biases")
98 |
99 | convolution = tf.nn.conv2d(input, W, strides=[1, 1, 1, 1], padding="SAME")
100 | activation = tf.nn.relu(convolution + B)
101 |
102 | tf.summary.histogram("weights", W)
103 | tf.summary.histogram("biases", B)
104 | tf.summary.histogram("activations", activation)
105 |
106 | return tf.nn.max_pool(activation, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
107 |
108 | def fully_connected_layer(input, size_in, size_out, name="fully_connected"):
109 | """
110 | Fully connected layer. This defines the fully connected layer.
111 | Different from the convolution layer, this layer does not
112 | perform a convolution but only defines an activation function.
113 | That function is also different from the convolution layer
114 | by multipliying the input data with its weights plus the biases,
115 | which is a much simpler activation function than ReLU.
116 |
117 | Parameters
118 | ----------
119 | size_in, size_out: int or float
120 | Where to truncate the normal distribution.
121 |
122 | name: str
123 | Name to give the TensorFlow scope.
124 | """
125 | with tf.name_scope(name):
126 |
127 | W = tf.Variable(tf.truncated_normal([size_in, size_out], stddev=0.1), name="Weights")
128 | B = tf.Variable(tf.constant(0.1, shape=[size_out]), name="Biases")
129 |
130 | activation = tf.matmul(input, W) + B
131 |
132 | tf.summary.histogram("weights", W)
133 | tf.summary.histogram("biases", B)
134 | tf.summary.histogram("activations", activation)
135 |
136 | return activation
137 |
138 | def model(mnist, learning_rate, epochs=2000):
139 | """
140 | Neural network model used in the MNIST dataset.
141 |
142 | Parameters
143 | ----------
144 | mnist: TensorFlow dataset object
145 | MNIST dataset loaded using TensorFlow.
146 |
147 | learning_rate: float
148 | Learning rate at which the network should
149 | create momentum.
150 |
151 | epochs: int, default 2000
152 | Number of epochs to train the model with.
153 | """
154 | name = "MNIST-model/lr={}-epochs={}".format(learning_rate, epochs)
155 |
156 | tf.reset_default_graph()
157 | sess = tf.Session()
158 |
159 | X = tf.placeholder(tf.float32, shape=[None, 784], name="X")
160 | X_image = tf.reshape(X, [-1, 28, 28, 1])
161 | tf.summary.image('input', X_image, 3)
162 |
163 | Y = tf.placeholder(tf.float32, shape=[None, 10], name="Labels")
164 |
165 | #
166 | # Convolutional layer treatment. We use a
167 | # single convolutional layer.
168 | #
169 | convolution = convolutional_layer(X_image, 1, 64, "Convolution_Layer")
170 | convolution_output = tf.nn.max_pool(convolution, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
171 |
172 | flattened = tf.reshape(convolution_output, [-1, 7 * 7 * 64])
173 |
174 | #
175 | # Fully-connected layer treatment.
176 | # We will use two fully connected layers
177 | # that connect to each other. We can
178 | # try more or less to see the impact
179 | # on our model.
180 | #
181 | fully_connected_1 = fully_connected_layer(flattened, 7 * 7 * 64, 1024, "Fully-connected_Layer_1")
182 | relu = tf.nn.relu(fully_connected_1)
183 | embedding_input = relu
184 | tf.summary.histogram("Fully-connected_Layer-1/relu", relu)
185 |
186 | embedding_size = 1024
187 | logits = fully_connected_layer(fully_connected_1, 1024, 10, "Fully-connected_Layer_2")
188 |
189 | with tf.name_scope("Cross_Entropy"):
190 | cross_entropy = tf.reduce_mean(
191 | tf.nn.softmax_cross_entropy_with_logits(
192 | logits=logits, labels=Y), name="cross_entropy")
193 |
194 | tf.summary.scalar("cross_entropy", cross_entropy)
195 |
196 | with tf.name_scope("Train"):
197 | train_step = tf.train.AdamOptimizer(learning_rate).minimize(cross_entropy)
198 |
199 | with tf.name_scope("Accuracy"):
200 | correct_prediction = tf.equal(tf.argmax(logits, 1), tf.argmax(Y, 1))
201 | accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
202 |
203 | tf.summary.scalar("Accuracy", accuracy)
204 |
205 | summ = tf.summary.merge_all()
206 |
207 | #
208 | # Let's save embeddings so that they
209 | # are available in TensorBoard.
210 | #
211 | embedding = tf.Variable(tf.zeros([1024, embedding_size]), name="Test_Embedding")
212 | assignment = embedding.assign(embedding_input)
213 | saver = tf.train.Saver()
214 |
215 | #
216 | # We can now run our TensorFlow session.
217 | #
218 | sess.run(tf.global_variables_initializer())
219 | writer = tf.summary.FileWriter(LOGDIR + name)
220 | writer.add_graph(sess.graph)
221 |
222 | config = tf.contrib.tensorboard.plugins.projector.ProjectorConfig()
223 | embedding_config = config.embeddings.add()
224 | embedding_config.tensor_name = embedding.name
225 | embedding_config.sprite.image_path = SPRITES
226 | embedding_config.metadata_path = LABELS
227 |
228 | #
229 | # Create each thumbnail.
230 | #
231 | embedding_config.sprite.single_image_dim.extend([28, 28])
232 | tf.contrib.tensorboard.plugins.projector.visualize_embeddings(writer, config)
233 |
234 | for i in tqdm.tqdm(range(epochs + 1), 'Epochs'):
235 | batch = mnist.train.next_batch(100)
236 |
237 | if i % 5 == 0:
238 | [train_accuracy, s] = sess.run([accuracy, summ], feed_dict={X: batch[0], Y: batch[1]})
239 | writer.add_summary(s, i)
240 | if i % 500 == 0:
241 | sess.run(assignment, feed_dict={X: mnist.test.images[:1024], Y: mnist.test.labels[:1024]})
242 | saver.save(sess, os.path.join(LOGDIR, "model.ckpt"), i)
243 |
244 | sess.run(train_step, feed_dict={X: batch[0], Y: batch[1]})
245 |
246 | print('Done training!')
247 | print('Run `tensorboard --logdir=%s` to see the results.' % LOGDIR)
248 | print("""
249 | Running on mac? If you want to get rid of the dialogue asking to give
250 | network permissions to TensorBoard, you can provide this flag:
251 | --host=localhost
252 | """)
253 |
254 | def main():
255 | """
256 | Main runner function. This calls the model function.
257 | """
258 | print("""
259 | Running MNIST model with:
260 |
261 | * Learning rate: {}
262 | * Epochs: {}
263 |
264 | """.format(LEARNING_RATE, EPOCHS))
265 |
266 | mnist = load_data()
267 | model(mnist=mnist, learning_rate=LEARNING_RATE, epochs=EPOCHS)
268 |
269 |
270 | if __name__ == '__main__':
271 | main()
272 |
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/MNIST-model.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/MNIST-model.zip
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/checkpoint:
--------------------------------------------------------------------------------
1 | model_checkpoint_path: "model.ckpt-2000"
2 | all_model_checkpoint_paths: "model.ckpt-0"
3 | all_model_checkpoint_paths: "model.ckpt-500"
4 | all_model_checkpoint_paths: "model.ckpt-1000"
5 | all_model_checkpoint_paths: "model.ckpt-1500"
6 | all_model_checkpoint_paths: "model.ckpt-2000"
7 |
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/data.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/data.zip
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-0.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-0.index
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-0.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-0.meta
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-1000.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-1000.index
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-1000.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-1000.meta
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-1500.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-1500.index
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-1500.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-1500.meta
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-2000.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-2000.index
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-2000.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-2000.meta
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-500.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-500.index
--------------------------------------------------------------------------------
/Chapter-4/activity_2/mnist_example/model.ckpt-500.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-4/activity_2/mnist_example/model.ckpt-500.meta
--------------------------------------------------------------------------------
/Chapter-4/activity_2/requirements.txt:
--------------------------------------------------------------------------------
1 | appnope==0.1.0
2 | beautifulsoup4==4.6.0
3 | bleach==1.5.0
4 | certifi==2017.11.5
5 | chardet==3.0.4
6 | click==6.7
7 | colorama==0.3.9
8 | coverage==4.4.2
9 | cycler==0.10.0
10 | decorator==4.1.2
11 | entrypoints==0.2.3
12 | enum34==1.1.6
13 | Flask==0.12.2
14 | Flask-API==1.0
15 | Flask-Caching==1.3.3
16 | Flask-Cors==3.0.3
17 | Flask-Testing==0.7.1
18 | graphviz==0.8.1
19 | h5py==2.7.1
20 | html5lib==0.9999999
21 | idna==2.6
22 | ipykernel==4.7.0
23 | ipython==6.2.1
24 | ipython-genutils==0.2.0
25 | ipywidgets==7.0.5
26 | itsdangerous==0.24
27 | jedi==0.11.1
28 | Jinja2==2.10
29 | jsonschema==2.6.0
30 | jupyter==1.0.0
31 | jupyter-client==5.1.0
32 | jupyter-console==5.2.0
33 | jupyter-core==4.4.0
34 | Keras==2.1.2
35 | lesscpy==0.12.0
36 | lxml==4.1.1
37 | Markdown==2.6.10
38 | MarkupSafe==1.0
39 | matplotlib==2.1.0
40 | mistune==0.8.3
41 | nbconvert==5.3.1
42 | nbformat==4.4.0
43 | nose==1.3.7
44 | notebook==5.2.2
45 | numpy==1.13.3
46 | pandas==0.21.1
47 | pandocfilters==1.4.2
48 | parso==0.1.1
49 | pexpect==4.3.1
50 | pickleshare==0.7.4
51 | ply==3.10
52 | prompt-toolkit==1.0.15
53 | protobuf==3.5.0.post1
54 | ptyprocess==0.5.2
55 | pydot==1.2.3
56 | Pygments==2.2.0
57 | pyparsing==2.2.0
58 | python-dateutil==2.6.1
59 | pytz==2017.3
60 | PyYAML==3.12
61 | pyzmq==16.0.3
62 | qtconsole==4.3.1
63 | redis==2.10.6
64 | rednose==1.2.3
65 | requests==2.18.4
66 | scipy==1.0.0
67 | seaborn==0.8.1
68 | simplegeneric==0.8.1
69 | six==1.11.0
70 | tensorflow==1.4.0
71 | tensorflow-tensorboard==0.4.0rc3
72 | terminado==0.8.1
73 | termstyle==0.1.11
74 | testpath==0.3.1
75 | tornado==4.5.2
76 | tqdm==4.19.4
77 | traitlets==4.3.2
78 | urllib3==1.22
79 | wcwidth==0.1.7
80 | Werkzeug==0.13
81 | widgetsnbextension==3.0.8
82 |
--------------------------------------------------------------------------------
/Chapter-5/activity_3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-5/activity_3.zip
--------------------------------------------------------------------------------
/Chapter-5/activity_4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-5/activity_4.zip
--------------------------------------------------------------------------------
/Chapter-5/activity_5.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-5/activity_5.zip
--------------------------------------------------------------------------------
/Chapter-6/activity_6.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-6/activity_6.zip
--------------------------------------------------------------------------------
/Chapter-6/activity_7.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-6/activity_7.zip
--------------------------------------------------------------------------------
/Chapter-7/activity_8.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-7/activity_8.zip
--------------------------------------------------------------------------------
/Chapter-7/activity_9.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TrainingByPackt/Applied-Deep-Learning-with-Python/ea55d1de2b636d2ff35d59ee1264c75f34b87322/Chapter-7/activity_9.zip
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/data/countries/interest-rates.csv:
--------------------------------------------------------------------------------
1 | Country or currency union;Central bank interest rate (%);Date of last change
2 | Albania;1.05;4 May 2016
3 | Angola;16.0;30 June 2016
4 | Argentina;26.25;11 April 2017
5 | Armenia;6.0;14 February 2017
6 | Australia;1.5;2 August 2016
7 | Azerbaijan;15.0;9 September 2016
8 | Bahamas;4.0;22 December 2016
9 | Bahrain;1.51;14 June 2017
10 | Bangladesh;6.75;14 January 2016
11 | Belarus;12.0;28 June 2017
12 | Botswana;5.5;12 August 2016
13 | Brazil;7.25;26 July 2017
14 | Bulgaria;0.0;29 January 2016
15 | Canada;1.25;17 January 2018
16 | Cape Verde;3.5;16 February 2015
17 | Central African States;2.95;22 March 2017
18 | Chile;2.5;8 May 2017
19 | China;1.75;23 October 2015
20 | Colombia;5.5;27 July 2017
21 | DR Congo;14.0;14 January 2017
22 | Croatia;2.5;20 October 2015
23 | Czech Republic;0.25;3 August 2017
24 | Denmark;-0.65;7 January 2016
25 | Dominican Republic;5.25;31 July 2017
26 | Egypt;18.75;6 July 2017
27 | Eurozone;0.0;10 March 2016
28 | Fiji;0.5;2 November 2011
29 | Gambia;20.0;9 May 2017
30 | Georgia;7.0;2 May 2017
31 | Ghana;20.0;24 July 2017
32 | Hong Kong;1.5;15 June 2017
33 | Hungary;0.9;24 May 2016
34 | Iceland;4.5;14 June 2017
35 | India;6.0;2 August 2017
36 | Indonesia;4.75;20 October 2016
37 | Iran;10.0;22 August 2017
38 | Israel;0.1;23 February 2015
39 | Jamaica;5.0;21 May 2016
40 | Japan;-0.1;29 January 2016
41 | Jordan;3.75;15 June 2017
42 | Kazakhstan;10.5;15 June 2017
43 | Kenya;10.0;20 September 2016
44 | Kuwait;2.75;15 March 2017
45 | Kyrgyzstan;5.0;27 December 2016
46 | Macedonia;3.25;15 February 2017
47 | Malawi;18.0;5 July 2017
48 | Malaysia;3.0;13 July 2016
49 | Mauritius;4.0;20 July 2016
50 | Mexico;7.0;22 June 2017
51 | Moldova;8.0;29 June 2017
52 | Mongolia;12.0;16 June 2017
53 | Morocco;2.25;22 March 2016
54 | Mozambique;21.75;15 April 2017
55 | Namibia;7.0;13 April 2016
56 | New Zealand;1.75;10 October 2016
57 | Nigeria;14.0;26 July 2016
58 | Norway;0.5;17 March 2016
59 | Pakistan;5.75;21 May 2016
60 | Paraguay;5.5;20 July 2016
61 | Peru;3.75;13 July 2017
62 | Philippines;3.0;3 June 2014
63 | Poland;1.5;4 March 2015
64 | Qatar;5.0;16 March 2017
65 | Romania;1.75;6 May 2015
66 | Russia;7.25;23 March 2018
67 | Rwanda;6.0;27 June 2017
68 | Samoa;0.14;1 July 2016
69 | Saudi Arabia;2.0;19 January 2009
70 | Serbia;3.5;9 October 2017
71 | Sierra Leone;13.0;15 June 2017
72 | South Africa;6.75;21 July 2017
73 | South Korea;1.25;9 June 2016
74 | Sri Lanka;7.25;23 March 2017
75 | Sweden;-0.5;11 February 2016
76 | Switzerland;-0.75;15 January 2015
77 | Taiwan;1.375;30 June 2016
78 | Tajikistan;16.0;20 March 2017
79 | Thailand;1.5;29 April 2015
80 | Trinidad and Tobago;4.75;4 December 2015
81 | Tunisia;5.0;24 May 2017
82 | Turkey;8.0;24 November 2016
83 | Uganda;10.0;19 June 2017
84 | Ukraine;12.5;26 May 2017
85 | UAE;2.0;14 June 2017
86 | United Kingdom;0.5;2 November 2017
87 | United States;1.5;13 December 2017
88 | Uzbekistan;9.0;1 January 2015
89 | Vietnam;6.25;7 July 2017
90 | West African States;3.5;16 September 2013
91 | Zambia;12.5;17 May 2017
92 |
--------------------------------------------------------------------------------
/data/countries/merged.csv:
--------------------------------------------------------------------------------
1 | Country,Population,Yearly Change,Interest rate,Date of last change
2 | China,1415045928.0,0.39,1.75,2015-10-23
3 | India,1354051854.0,1.11,6.0,2017-08-02
4 | United States,326766748.0,0.71,1.5,2017-12-13
5 | Indonesia,266794980.0,1.06,4.75,2016-10-20
6 | Brazil,210867954.0,0.75,7.25,2017-07-26
7 | Pakistan,200813818.0,1.93,5.75,2016-05-21
8 | Nigeria,195875237.0,2.61,14.0,2016-07-26
9 | Bangladesh,166368149.0,1.03,6.75,2016-01-14
10 | Russia,143964709.0,-0.02,7.25,2018-03-23
11 | Mexico,130759074.0,1.24,7.0,2017-06-22
12 | Japan,127185332.0,-0.23,-0.1,2016-01-29
13 | Philippines,106512074.0,1.52,3.0,2014-06-03
14 | Egypt,99375741.0,1.87,18.75,2017-07-06
15 | DR Congo,84004989.0,3.28,14.0,2017-01-14
16 | Iran,82011735.0,1.05,10.0,2017-08-22
17 | Turkey,81916871.0,1.45,8.0,2016-11-24
18 | Thailand,69183173.0,0.21,1.5,2015-04-29
19 | South Africa,57398421.0,1.2,6.75,2017-07-21
20 | South Korea,51164435.0,0.36,1.25,2016-06-09
21 | Kenya,50950879.0,2.52,10.0,2016-09-20
22 | Colombia,49464683.0,0.81,5.5,2017-07-27
23 | Argentina,44688864.0,0.94,26.25,2017-04-11
24 | Uganda,44270563.0,3.28,10.0,2017-06-19
25 | Ukraine,44009214.0,-0.48,12.5,2017-05-26
26 | Poland,38104832.0,-0.17,1.5,2015-03-04
27 | Canada,36953765.0,0.9,1.25,2018-01-17
28 | Morocco,36191805.0,1.27,2.25,2016-03-22
29 | Saudi Arabia,33554343.0,1.87,2.0,2009-01-19
30 | Peru,32551815.0,1.2,3.75,2017-07-13
31 | Uzbekistan,32364996.0,1.42,9.0,2015-01-01
32 | Malaysia,32042458.0,1.32,3.0,2016-07-13
33 | Angola,30774205.0,3.32,16.0,2016-06-30
34 | Mozambique,30528673.0,2.9,21.75,2017-04-15
35 | Ghana,29463643.0,2.18,20.0,2017-07-24
36 | Australia,24772247.0,1.32,1.5,2016-08-02
37 | Taiwan,23694089.0,0.29,1.375,2016-06-30
38 | Sri Lanka,20950041.0,0.35,7.25,2017-03-23
39 | Romania,19580634.0,-0.5,1.75,2015-05-06
40 | Malawi,19164728.0,2.91,18.0,2017-07-05
41 | Kazakhstan,18403860.0,1.1,10.5,2017-06-15
42 | Chile,18197209.0,0.79,2.5,2017-05-08
43 | Zambia,17609178.0,3.01,12.5,2017-05-17
44 | Rwanda,12501156.0,2.4,6.0,2017-06-27
45 | Tunisia,11659174.0,1.1,5.0,2017-05-24
46 | Dominican Republic,10882996.0,1.08,5.25,2017-07-31
47 | Czech Republic,10625250.0,0.07,0.25,2017-08-03
48 | Sweden,9982709.0,0.73,-0.5,2016-02-11
49 | Azerbaijan,9923914.0,0.98,15.0,2016-09-09
50 | Jordan,9903802.0,2.08,3.75,2017-06-15
51 | Hungary,9688847.0,-0.34,0.9,2016-05-24
52 | Belarus,9452113.0,-0.17,12.0,2017-06-28
53 | Tajikistan,9107211.0,2.08,16.0,2017-03-20
54 | Serbia,8762027.0,-0.32,3.5,2017-10-09
55 | Switzerland,8544034.0,0.8,-0.75,2015-01-15
56 | Israel,8452841.0,1.58,0.1,2015-02-23
57 | Sierra Leone,7719729.0,2.15,13.0,2017-06-15
58 | Hong Kong,7428887.0,0.87,1.5,2017-06-15
59 | Bulgaria,7036848.0,-0.67,0.0,2016-01-29
60 | Paraguay,6896908.0,1.26,5.5,2016-07-20
61 | Kyrgyzstan,6132932.0,1.45,5.0,2016-12-27
62 | Denmark,5754356.0,0.36,-0.65,2016-01-07
63 | Norway,5353363.0,0.9,0.5,2016-03-17
64 | New Zealand,4749598.0,0.93,1.75,2016-10-10
65 | Kuwait,4197128.0,1.46,2.75,2017-03-15
66 | Croatia,4164783.0,-0.59,2.5,2015-10-20
67 | Moldova,4041065.0,-0.25,8.0,2017-06-29
68 | Georgia,3907131.0,-0.13,7.0,2017-05-02
69 | Mongolia,3121772.0,1.5,12.0,2017-06-16
70 | Albania,2934363.0,0.14,1.05,2016-05-04
71 | Armenia,2934152.0,0.13,6.0,2017-02-14
72 | Jamaica,2898677.0,0.29,5.0,2016-05-21
73 | Qatar,2694849.0,2.11,5.0,2017-03-16
74 | Namibia,2587801.0,2.13,7.0,2016-04-13
75 | Botswana,2333201.0,1.81,5.5,2016-08-12
76 | Gambia,2163765.0,3.01,20.0,2017-05-09
77 | Bahrain,1566993.0,4.99,1.51,2017-06-14
78 | Trinidad and Tobago,1372598.0,0.25,4.75,2015-12-04
79 | Mauritius,1268315.0,0.25,4.0,2016-07-20
80 | Fiji,912241.0,0.74,0.5,2011-11-02
81 | Bahamas,399285.0,0.99,4.0,2016-12-22
82 | Iceland,337780.0,0.82,4.5,2017-06-14
83 | Samoa,197695.0,0.64,0.14,2016-07-01
84 |
--------------------------------------------------------------------------------
/data/countries/populations.csv:
--------------------------------------------------------------------------------
1 | Country (or dependency);Population (2018);Yearly Change
2 | China;1,415,045,928;0.39 %
3 | India;1,354,051,854;1.11 %
4 | U.S.;326,766,748;0.71 %
5 | Indonesia;266,794,980;1.06 %
6 | Brazil;210,867,954;0.75 %
7 | Pakistan;200,813,818;1.93 %
8 | Nigeria;195,875,237;2.61 %
9 | Bangladesh;166,368,149;1.03 %
10 | Russia;143,964,709;-0.02 %
11 | Mexico;130,759,074;1.24 %
12 | Japan;127,185,332;-0.23 %
13 | Ethiopia;107,534,882;2.46 %
14 | Philippines;106,512,074;1.52 %
15 | Egypt;99,375,741;1.87 %
16 | Viet Nam;96,491,146;0.99 %
17 | DR Congo;84,004,989;3.28 %
18 | Germany;82,293,457;0.22 %
19 | Iran;82,011,735;1.05 %
20 | Turkey;81,916,871;1.45 %
21 | Thailand;69,183,173;0.21 %
22 | U.K.;66,573,504;0.59 %
23 | France;65,233,271;0.39 %
24 | Italy;59,290,969;-0.12 %
25 | Tanzania;59,091,392;3.11 %
26 | South Africa;57,398,421;1.20 %
27 | Myanmar;53,855,735;0.91 %
28 | South Korea;51,164,435;0.36 %
29 | Kenya;50,950,879;2.52 %
30 | Colombia;49,464,683;0.81 %
31 | Spain;46,397,452;0.09 %
32 | Argentina;44,688,864;0.94 %
33 | Uganda;44,270,563;3.28 %
34 | Ukraine;44,009,214;-0.48 %
35 | Algeria;42,008,054;1.67 %
36 | Sudan;41,511,526;2.41 %
37 | Iraq;39,339,753;2.78 %
38 | Poland;38,104,832;-0.17 %
39 | Canada;36,953,765;0.90 %
40 | Afghanistan;36,373,176;2.37 %
41 | Morocco;36,191,805;1.27 %
42 | Saudi Arabia;33,554,343;1.87 %
43 | Peru;32,551,815;1.20 %
44 | Venezuela;32,381,221;1.26 %
45 | Uzbekistan;32,364,996;1.42 %
46 | Malaysia;32,042,458;1.32 %
47 | Angola;30,774,205;3.32 %
48 | Mozambique;30,528,673;2.90 %
49 | Nepal;29,624,035;1.09 %
50 | Ghana;29,463,643;2.18 %
51 | Yemen;28,915,284;2.35 %
52 | Madagascar;26,262,810;2.71 %
53 | North Korea;25,610,672;0.47 %
54 | Côte d'Ivoire;24,905,843;2.52 %
55 | Australia;24,772,247;1.32 %
56 | Cameroon;24,678,234;2.60 %
57 | Taiwan;23,694,089;0.29 %
58 | Niger;22,311,375;3.88 %
59 | Sri Lanka;20,950,041;0.35 %
60 | Burkina Faso;19,751,651;2.91 %
61 | Romania;19,580,634;-0.50 %
62 | Malawi;19,164,728;2.91 %
63 | Mali;19,107,706;3.05 %
64 | Kazakhstan;18,403,860;1.10 %
65 | Syria;18,284,407;0.08 %
66 | Chile;18,197,209;0.79 %
67 | Zambia;17,609,178;3.01 %
68 | Guatemala;17,245,346;1.96 %
69 | Netherlands;17,084,459;0.28 %
70 | Zimbabwe;16,913,261;2.32 %
71 | Ecuador;16,863,425;1.44 %
72 | Senegal;16,294,270;2.80 %
73 | Cambodia;16,245,729;1.50 %
74 | Chad;15,353,184;3.04 %
75 | Somalia;15,181,925;2.98 %
76 | Guinea;13,052,608;2.64 %
77 | South Sudan;12,919,053;2.73 %
78 | Rwanda;12,501,156;2.40 %
79 | Tunisia;11,659,174;1.10 %
80 | Belgium;11,498,519;0.61 %
81 | Cuba;11,489,082;0.04 %
82 | Benin;11,485,674;2.77 %
83 | Burundi;11,216,450;3.24 %
84 | Bolivia;11,215,674;1.48 %
85 | Greece;11,142,161;-0.16 %
86 | Haiti;11,112,945;1.20 %
87 | Dominican Republic;10,882,996;1.08 %
88 | Czech Republic;10,625,250;0.07 %
89 | Portugal;10,291,196;-0.37 %
90 | Sweden;9,982,709;0.73 %
91 | Azerbaijan;9,923,914;0.98 %
92 | Jordan;9,903,802;2.08 %
93 | Hungary;9,688,847;-0.34 %
94 | United Arab Emirates;9,541,615;1.50 %
95 | Belarus;9,452,113;-0.17 %
96 | Honduras;9,417,167;1.64 %
97 | Tajikistan;9,107,211;2.08 %
98 | Serbia;8,762,027;-0.32 %
99 | Austria;8,751,820;0.19 %
100 | Switzerland;8,544,034;0.80 %
101 | Israel;8,452,841;1.58 %
102 | Papua New Guinea;8,418,346;2.03 %
103 | Togo;7,990,926;2.48 %
104 | Sierra Leone;7,719,729;2.15 %
105 | Hong Kong;7,428,887;0.87 %
106 | Bulgaria;7,036,848;-0.67 %
107 | Laos;6,961,210;1.50 %
108 | Paraguay;6,896,908;1.26 %
109 | Libya;6,470,956;1.51 %
110 | El Salvador;6,411,558;0.53 %
111 | Nicaragua;6,284,757;1.08 %
112 | Kyrgyzstan;6,132,932;1.45 %
113 | Lebanon;6,093,509;0.18 %
114 | Turkmenistan;5,851,466;1.62 %
115 | Singapore;5,791,901;1.45 %
116 | Denmark;5,754,356;0.36 %
117 | Finland;5,542,517;0.35 %
118 | Slovakia;5,449,816;0.04 %
119 | Congo;5,399,895;2.64 %
120 | Norway;5,353,363;0.90 %
121 | Eritrea;5,187,948;2.35 %
122 | State of Palestine;5,052,776;2.68 %
123 | Costa Rica;4,953,199;0.97 %
124 | Liberia;4,853,516;2.57 %
125 | Oman;4,829,946;4.18 %
126 | Ireland;4,803,748;0.88 %
127 | New Zealand;4,749,598;0.93 %
128 | Central African Republic;4,737,423;1.68 %
129 | Mauritania;4,540,068;2.71 %
130 | Kuwait;4,197,128;1.46 %
131 | Croatia;4,164,783;-0.59 %
132 | Panama;4,162,618;1.56 %
133 | Moldova;4,041,065;-0.25 %
134 | Georgia;3,907,131;-0.13 %
135 | Puerto Rico;3,659,007;-0.11 %
136 | Bosnia & Herzegovina;3,503,554;-0.10 %
137 | Uruguay;3,469,551;0.37 %
138 | Mongolia;3,121,772;1.50 %
139 | Albania;2,934,363;0.14 %
140 | Armenia;2,934,152;0.13 %
141 | Jamaica;2,898,677;0.29 %
142 | Lithuania;2,876,475;-0.48 %
143 | Qatar;2,694,849;2.11 %
144 | Namibia;2,587,801;2.13 %
145 | Botswana;2,333,201;1.81 %
146 | Lesotho;2,263,010;1.33 %
147 | Gambia;2,163,765;3.01 %
148 | TFYR Macedonia;2,085,051;0.09 %
149 | Slovenia;2,081,260;0.06 %
150 | Gabon;2,067,561;2.09 %
151 | Latvia;1,929,938;-1.01 %
152 | Guinea-Bissau;1,907,268;2.47 %
153 | Bahrain;1,566,993;4.99 %
154 | Swaziland;1,391,385;1.76 %
155 | Trinidad and Tobago;1,372,598;0.25 %
156 | Timor-Leste;1,324,094;2.14 %
157 | Equatorial Guinea;1,313,894;3.64 %
158 | Estonia;1,306,788;-0.22 %
159 | Mauritius;1,268,315;0.25 %
160 | Cyprus;1,189,085;0.81 %
161 | Djibouti;971,408;1.51 %
162 | Fiji;912,241;0.74 %
163 | Réunion;883,247;0.76 %
164 | Comoros;832,347;2.26 %
165 | Bhutan;817,054;1.17 %
166 | Guyana;782,225;0.56 %
167 | Macao;632,418;1.58 %
168 | Montenegro;629,219;0.04 %
169 | Solomon Islands;623,281;1.95 %
170 | Luxembourg;590,321;1.18 %
171 | Suriname;568,301;0.87 %
172 | Western Sahara;567,421;2.68 %
173 | Cabo Verde;553,335;1.27 %
174 | Guadeloupe;449,173;-0.09 %
175 | Maldives;444,259;1.82 %
176 | Brunei ;434,076;1.25 %
177 | Malta;432,089;0.29 %
178 | Bahamas;399,285;0.99 %
179 | Martinique;385,065;0.04 %
180 | Belize;382,444;2.07 %
181 | Iceland;337,780;0.82 %
182 | French Guiana;289,763;2.49 %
183 | Barbados;286,388;0.23 %
184 | French Polynesia;285,859;1.01 %
185 | Vanuatu;282,117;2.13 %
186 | New Caledonia;279,821;1.29 %
187 | Mayotte;259,682;2.62 %
188 | Sao Tome & Principe;208,818;2.20 %
189 | Samoa;197,695;0.64 %
190 | Saint Lucia;179,667;0.46 %
191 | Channel Islands;166,083;0.47 %
192 | Guam;165,718;0.91 %
193 | Curaçao;161,577;0.65 %
194 | Kiribati;118,414;1.73 %
195 | St. Vincent & Grenadines;110,200;0.28 %
196 | Tonga;109,008;0.91 %
197 | Grenada;108,339;0.48 %
198 | Micronesia;106,227;0.65 %
199 | Aruba;105,670;0.39 %
200 | U.S. Virgin Islands;104,914;0.01 %
201 | Antigua and Barbuda;103,050;1.02 %
202 | Seychelles;95,235;0.53 %
203 | Isle of Man;84,831;0.65 %
204 | Andorra;76,953;-0.02 %
205 | Dominica;74,308;0.52 %
206 | Cayman Islands;62,348;1.28 %
207 | Bermuda;61,070;-0.45 %
208 | Greenland;56,565;0.15 %
209 | Saint Kitts & Nevis;55,850;0.91 %
210 | American Samoa;55,679;0.07 %
211 | Northern Mariana Islands;55,194;0.09 %
212 | Marshall Islands;53,167;0.08 %
213 | Faeroe Islands;49,489;0.40 %
214 | Sint Maarten;40,552;1.08 %
215 | Monaco;38,897;0.52 %
216 | Liechtenstein;38,155;0.61 %
217 | Turks and Caicos;35,963;1.46 %
218 | Gibraltar;34,733;0.47 %
219 | San Marino;33,557;0.47 %
220 | British Virgin Islands;31,719;1.68 %
221 | Caribbean Netherlands;25,702;1.20 %
222 | Palau;21,964;1.08 %
223 | Cook Islands;17,411;0.18 %
224 | Anguilla;15,045;0.91 %
225 | Wallis & Futuna;11,683;-0.76 %
226 | Nauru;11,312;-0.41 %
227 | Tuvalu;11,287;0.85 %
228 | Saint Pierre & Miquelon;6,342;0.35 %
229 | Montserrat;5,203;0.50 %
230 | Saint Helena;4,074;0.62 %
231 | Falkland Islands;2,922;0.41 %
232 | Niue;1,624;0.37 %
233 | Tokelau;1,319;1.46 %
234 | Holy See;801;1.14 %
235 |
--------------------------------------------------------------------------------