Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add files via upload
The Python files I used to test the runtimes on my local computer and the cluster.
- Loading branch information
Showing
3 changed files
with
912 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu Oct 29 16:22:11 2020 | ||
@author: jaych | ||
""" | ||
#%% | ||
#print("test") | ||
import time | ||
start = time.time() | ||
import tensorflow as tf | ||
#assert tf.__version__ >= "2.0" | ||
|
||
# Common imports | ||
import numpy as np | ||
import os | ||
#import numpy as np | ||
from numpy import loadtxt | ||
from keras.models import Sequential | ||
from keras.layers import Dense | ||
|
||
# to make this notebook's output stable across runs | ||
np.random.seed(42) | ||
|
||
# To plot pretty figures | ||
#%matplotlib inline | ||
import matplotlib as mpl | ||
import matplotlib.pyplot as plt | ||
# mpl.rc('axes', labelsize=14) | ||
# mpl.rc('xtick', labelsize=12) | ||
# mpl.rc('ytick', labelsize=12) | ||
|
||
|
||
#%% | ||
|
||
dataset = loadtxt('pima-indians-diabetes.csv.txt', delimiter=',') | ||
print(dataset.shape) | ||
X = dataset[:,0:8] | ||
y = dataset[:,8] | ||
|
||
#%% | ||
# define the keras model | ||
model = Sequential() | ||
model.add(Dense(12, input_dim=8, activation='relu')) | ||
model.add(Dense(8, activation='relu')) | ||
model.add(Dense(1, activation='sigmoid')) | ||
|
||
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | ||
#%% | ||
model.fit(X, y, epochs=1000, batch_size=10) | ||
#evaluate the keras model | ||
_, accuracy = model.evaluate(X, y) | ||
print('Accuracy: %.2f' % (accuracy*100)) | ||
|
||
|
||
model1 = Sequential() | ||
model1.add(Dense(12, input_dim=8, activation='relu')) | ||
model1.add(Dense(8, activation='relu')) | ||
model1.add(Dense(1, activation='sigmoid')) | ||
|
||
model1.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | ||
#%% | ||
model1.fit(X, y, epochs=3000, batch_size=10) | ||
#evaluate the keras model | ||
_, accuracy = model.evaluate(X, y) | ||
print('Accuracy: %.2f' % (accuracy*100)) | ||
|
||
|
||
|
||
#%% | ||
end = time.time() | ||
print(f"Runtime of the program is {end - start}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu Oct 29 16:22:11 2020 | ||
@author: jaych | ||
""" | ||
#%% | ||
#print("test") | ||
import time | ||
start = time.time() | ||
import tensorflow as tf | ||
#assert tf.__version__ >= "2.0" | ||
|
||
# Common imports | ||
import numpy as np | ||
import os | ||
#import numpy as np | ||
from numpy import loadtxt | ||
from keras.models import Sequential | ||
from keras.layers import Dense | ||
|
||
# to make this notebook's output stable across runs | ||
np.random.seed(42) | ||
|
||
# To plot pretty figures | ||
#%matplotlib inline | ||
import matplotlib as mpl | ||
import matplotlib.pyplot as plt | ||
# mpl.rc('axes', labelsize=14) | ||
# mpl.rc('xtick', labelsize=12) | ||
# mpl.rc('ytick', labelsize=12) | ||
|
||
|
||
#%% | ||
|
||
dataset = loadtxt('pima-indians-diabetes.csv.txt', delimiter=',') | ||
print(dataset.shape) | ||
X = dataset[:,0:8] | ||
y = dataset[:,8] | ||
|
||
#%% | ||
# define the keras model | ||
model = Sequential() | ||
model.add(Dense(12, input_dim=8, activation='relu')) | ||
model.add(Dense(8, activation='relu')) | ||
model.add(Dense(1, activation='sigmoid')) | ||
|
||
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | ||
#%% | ||
model.fit(X, y, epochs=1000, batch_size=10) | ||
#evaluate the keras model | ||
_, accuracy = model.evaluate(X, y) | ||
print('Accuracy: %.2f' % (accuracy*100)) | ||
|
||
|
||
model1 = Sequential() | ||
model1.add(Dense(12, input_dim=8, activation='relu')) | ||
model1.add(Dense(8, activation='relu')) | ||
model1.add(Dense(1, activation='sigmoid')) | ||
|
||
model1.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | ||
#%% | ||
model1.fit(X, y, epochs=3000, batch_size=10) | ||
#evaluate the keras model | ||
_, accuracy = model.evaluate(X, y) | ||
print('Accuracy: %.2f' % (accuracy*100)) | ||
|
||
|
||
|
||
#%% | ||
end = time.time() | ||
print(f"Runtime of the program is {end - start}") |
Oops, something went wrong.