Skip to content
Open

dock #70

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask

app = Flask(__name__)

@app.route("/demo/")
def hello_world():
import subprocess
subprocess.check_output("python3 demo.py", shell=1)
return "<p>Hello, World!</p>"

@app.route("/")
def hello_world1():
return "<p>OK!</p>"
if __name__ == '__main__':
app.run(debug=True, port=8080, host="0.0.0.0")
88 changes: 88 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:18.04

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

# 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 'flask run -h 0.0.0.0 -p 8080'
EXPOSE 8080
6 changes: 6 additions & 0 deletions docker/start_jupyter_notebook.sh
Original file line number Diff line number Diff line change
@@ -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=\"\"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy >= 1.14.2
cvxopt >= 1.2.0
matplotlib >= 2.1.0
matplotlib == 2.1.0
Flask==2.0.3