From 54d854aa1a8dfb3ae83172b74ddee93dcb3c854a Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 25 Oct 2023 21:17:50 +0000 Subject: [PATCH 01/15] dock --- docker/Dockerfile | 30 ++++++++++++++++++++++++++++++ docker/start_jupyter_notebook.sh | 6 ++++++ 2 files changed, 36 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/start_jupyter_notebook.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..4d8499c --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:18.04 + +MAINTAINER Mohit Rathore mrmohitrathoremr@gmail.com + +ENV REPOSITORY https://github.com/jellAIfish/fromscratchtoml.git +ENV BRANCH master + +RUN apt-get update +RUN apt-get install -y python3-pip git + +# Upgrade pip +RUN pip3 install --upgrade pip + +RUN git clone $REPOSITORY +WORKDIR /fromscratchtoml +RUN git checkout $BRANCH +RUN pip3 install -r requirements.txt +RUN pip3 install jupyter +RUN pip3 install scikit-learn==0.20.1 +RUN python3 setup.py install + +# Fix ipython kernel version +RUN ipython kernel install + +# Add running permission to startup script +RUN chmod +x /fromscratchtoml/docker/start_jupyter_notebook.sh + +# Define the starting command for this container and expose its running port +CMD sh -c '/fromscratchtoml/docker/start_jupyter_notebook.sh 8080' +EXPOSE 8080 diff --git a/docker/start_jupyter_notebook.sh b/docker/start_jupyter_notebook.sh new file mode 100644 index 0000000..e3998fb --- /dev/null +++ b/docker/start_jupyter_notebook.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +PORT=$1 +NOTEBOOK_DIR=/fromscratchtoml/docs/notebooks + +jupyter notebook --no-browser --ip=* --port=${PORT} --allow-root --notebook-dir=${NOTEBOOK_DIR} --NotebookApp.token=\"\" From e8223267173471baedb70ba6f77ec93f79da7c15 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 25 Oct 2023 17:32:27 -0400 Subject: [PATCH 02/15] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 065e6de..538d533 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ numpy >= 1.14.2 -cvxopt >= 1.2.0 matplotlib >= 2.1.0 From 4d2671fcdbf27ed3399ce242286be44c4877aa81 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 25 Oct 2023 17:37:04 -0400 Subject: [PATCH 03/15] Update Dockerfile --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4d8499c..9837012 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:18.04 MAINTAINER Mohit Rathore mrmohitrathoremr@gmail.com ENV REPOSITORY https://github.com/jellAIfish/fromscratchtoml.git -ENV BRANCH master +ENV BRANCH demo RUN apt-get update RUN apt-get install -y python3-pip git From 2d6fb08f8a2265da2bc19952f261b6799ac69048 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Tue, 28 Nov 2023 22:41:10 -0500 Subject: [PATCH 04/15] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 538d533..1389b73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ numpy >= 1.14.2 -matplotlib >= 2.1.0 +matplotlib == 2.1.0 From d643505caae537cc52c8dac61d131f3d51e4c76e Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Tue, 28 Nov 2023 22:42:35 -0500 Subject: [PATCH 05/15] Create app.py --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..0ce7e33 --- /dev/null +++ b/app.py @@ -0,0 +1,11 @@ +from flask import Flask + +app = Flask(__name__) + +@app.route("/") +def hello_world(): + import subprocess + subprocess.check_output("python3 demo.py", shell=1) + return "

Hello, World!

" +if __name__ == '__main__': + app.run(debug=True, port=8080) From 9ee031d4ba6627f8cd7f2e7991d4730549450f45 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Tue, 28 Nov 2023 22:43:10 -0500 Subject: [PATCH 06/15] Create demo.py --- demo.py | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 demo.py diff --git a/demo.py b/demo.py new file mode 100644 index 0000000..5c9d5d4 --- /dev/null +++ b/demo.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[1]: + + +from fromscratchtoml.neural_network.models import Sequential +from fromscratchtoml.neural_network.optimizers import StochasticGradientDescent +from fromscratchtoml.neural_network.layers import Dense, Activation + + +import numpy as np +from sklearn.model_selection import train_test_split + +from fromscratchtoml.toolbox.random import Distribution +from fromscratchtoml.toolbox.preprocess import to_onehot +import os +os.environ['OPENBLAS_NUM_THREADS'] = '1' +os.environ['MKL_NUM_THREADS'] = '1' +from sklearn import datasets +from sklearn.utils import shuffle + +from fromscratchtoml.toolbox import binary_visualize + + + +# ## Radial + +# In[2]: + + +X11 = Distribution.radial_binary(pts=300, + mean=[0, 0], + st=1, + ed=2, seed=20) +X22 = Distribution.radial_binary(pts=300, + mean=[0, 0], + st=4, + ed=5, seed=20) + +Y11 = np.ones(X11.shape[0]) +Y22 = np.zeros(X11.shape[0]) + +X5 = np.vstack((X11, X22)) +y5 = np.hstack((Y11, Y22)) + + +# In[3]: + + +y5 = to_onehot(y5) + + +# In[4]: + + +X_train5, X_test5, y_train5, y_test5 = train_test_split(X5, y5, test_size=50, random_state=42) + + +# In[5]: + + +y_train5.shape + + +# In[6]: + + +model5 = Sequential(verbose=1, vis_each_epoch=True) +model5.add(Dense(10, input_dim=2, seed=1)) +model5.add(Activation('sigmoid')) +model5.add(Dense(2, seed=2)) +model5.add(Activation('sigmoid')) +model5.add(Dense(2, seed=3)) +# model5.add(Activation('sigmoid')) +sgd = StochasticGradientDescent(learning_rate=0.005) +model5.compile(optimizer=sgd, loss="mean_squared_error") + + +# In[7]: + +model5.fit(X_train5, y_train5, batch_size=16, epochs=40) + + +# In[8]: + + +binary_visualize(X_test5, clf=model5, draw_contour=True) From cf14f02bc73102d1c7c16240b728d0ced91d5e4d Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 29 Nov 2023 18:45:48 -0500 Subject: [PATCH 07/15] Update Dockerfile --- docker/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9837012..16a88b4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,6 +5,8 @@ MAINTAINER Mohit Rathore mrmohitrathoremr@gmail.com ENV REPOSITORY https://github.com/jellAIfish/fromscratchtoml.git ENV BRANCH demo +ENV LC_ALL C.UTF-8 +ENV LANG C.UTF-8 RUN apt-get update RUN apt-get install -y python3-pip git @@ -26,5 +28,5 @@ RUN ipython kernel install RUN chmod +x /fromscratchtoml/docker/start_jupyter_notebook.sh # Define the starting command for this container and expose its running port -CMD sh -c '/fromscratchtoml/docker/start_jupyter_notebook.sh 8080' +CMD sh -c 'flask run -h 0.0.0.0 -p 8080' EXPOSE 8080 From 7a95e81fb81a62ed415d48c6788d2a63efb2a045 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 29 Nov 2023 18:49:28 -0500 Subject: [PATCH 08/15] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 1389b73..8b05a92 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ numpy >= 1.14.2 matplotlib == 2.1.0 +Flask==2.0.3 From 7c60def90fa0e63452380ef47bda9a98962482ea Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 29 Nov 2023 20:04:07 -0500 Subject: [PATCH 09/15] Update app.py --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 0ce7e33..b7b4a8b 100644 --- a/app.py +++ b/app.py @@ -2,10 +2,14 @@ app = Flask(__name__) -@app.route("/") +@app.route("/demo") def hello_world(): import subprocess subprocess.check_output("python3 demo.py", shell=1) return "

Hello, World!

" + +@app.route("/") +def hello_world1(): + return "

OK!

" if __name__ == '__main__': app.run(debug=True, port=8080) From b05d1d0087fdd3371876664dc268d28146f7f8c6 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Wed, 29 Nov 2023 23:25:23 -0500 Subject: [PATCH 10/15] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index b7b4a8b..2f330a3 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ app = Flask(__name__) -@app.route("/demo") +@app.route("/demo/") def hello_world(): import subprocess subprocess.check_output("python3 demo.py", shell=1) From 5a5adabd486a86623efa68838a67b24da198cf7e Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Thu, 30 Nov 2023 00:07:39 -0500 Subject: [PATCH 11/15] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 2f330a3..ecacc9d 100644 --- a/app.py +++ b/app.py @@ -12,4 +12,4 @@ def hello_world(): def hello_world1(): return "

OK!

" if __name__ == '__main__': - app.run(debug=True, port=8080) + app.run(debug=True, port=8080, host="0.0.0.0") From e758f8e438d6efcaa6ec87eda2f8d480698a3f47 Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Thu, 30 Nov 2023 00:10:31 -0500 Subject: [PATCH 12/15] Update Dockerfile --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 16a88b4..9f706bb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,5 +28,5 @@ RUN ipython kernel install RUN chmod +x /fromscratchtoml/docker/start_jupyter_notebook.sh # Define the starting command for this container and expose its running port -CMD sh -c 'flask run -h 0.0.0.0 -p 8080' -EXPOSE 8080 +CMD sh -c 'flask run -h 0.0.0.0 -p 80' +EXPOSE 80 From 8f441334b11a0b64307e3137e4a10f139102fb8e Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Thu, 30 Nov 2023 00:10:52 -0500 Subject: [PATCH 13/15] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index ecacc9d..3d2f293 100644 --- a/app.py +++ b/app.py @@ -12,4 +12,4 @@ def hello_world(): def hello_world1(): return "

OK!

" if __name__ == '__main__': - app.run(debug=True, port=8080, host="0.0.0.0") + app.run(debug=True, port=80, host="0.0.0.0") From bf8e350f3323d07298434778c32386f71f16c71a Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Thu, 30 Nov 2023 00:25:24 -0500 Subject: [PATCH 14/15] Update Dockerfile --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9f706bb..16a88b4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,5 +28,5 @@ RUN ipython kernel install RUN chmod +x /fromscratchtoml/docker/start_jupyter_notebook.sh # Define the starting command for this container and expose its running port -CMD sh -c 'flask run -h 0.0.0.0 -p 80' -EXPOSE 80 +CMD sh -c 'flask run -h 0.0.0.0 -p 8080' +EXPOSE 8080 From a113a354a62de6c543037e30fe39032b29cba22b Mon Sep 17 00:00:00 2001 From: Mohit Rathore Date: Thu, 30 Nov 2023 00:25:37 -0500 Subject: [PATCH 15/15] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 3d2f293..ecacc9d 100644 --- a/app.py +++ b/app.py @@ -12,4 +12,4 @@ def hello_world(): def hello_world1(): return "

OK!

" if __name__ == '__main__': - app.run(debug=True, port=80, host="0.0.0.0") + app.run(debug=True, port=8080, host="0.0.0.0")