Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSE_SDP_G28_ML/HPC_Cluster_Test_long_runtime.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
72 lines (57 sloc)
1.68 KB
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
# -*- 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}") |