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
Poster |
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
model = models.Sequential([ | |
layers.Dense(128, activation = 'relu', input_shape = Xtrain[0].shape), | |
layers.Dense(64, activation = 'relu'), | |
#layers.Dense(16, activation = 'relu'), | |
layers.Dense(8, activation = 'relu'), | |
layers.Dense(1) | |
]) | |
cb = callbacks.EarlyStopping(patience = 10, restore_best_weights = True) |
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
# Splitting into train, val and test set -- 80-10-10 split | |
# First, an 80-20 split | |
train_df, val_test_df = train_test_split(df, test_size = 0.2) | |
# Then split the 20% into half | |
val_df, test_df = train_test_split(val_test_df, test_size = 0.5) | |
# Splitting into X (input) and y (output) |
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
# defining the input and output columns to separate the dataset in the later cells. | |
input_columns = df.columns.tolist() | |
input_columns.remove('label') | |
output_columns = ['label'] |
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
df[['red','green','blue']] /= 255 |
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
# pick random test data sample from one batch | |
x = random.randint(0, len(Xtest) - 1) | |
output = model.predict(Xtest[x].reshape(1, -1))[0] | |
pred = np.argmax(output) | |
print("Predicted: ", pred, "(", output[pred], ")") | |
print("True: ", np.argmax(np.array(ytest)[x])) |
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
model = models.Sequential([ | |
layers.Dense(256, activation = 'relu', input_shape = Xtrain[0].shape), | |
layers.Dense(64, activation = 'relu'), | |
layers.Dense(16, activation = 'relu'), | |
layers.Dense(4, activation = 'softmax') | |
]) | |
cb = [callbacks.EarlyStopping(patience = 5, restore_best_weights = True)] | |
model.compile(optimizer=optimizers.Adam(0.0001), loss=losses.CategoricalCrossentropy(), metrics=['accuracy']) |
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
ss_scaler = StandardScaler() | |
# Fit on training set alone | |
Xtrain = ss_scaler.fit_transform(Xtrain) | |
# Use it to transform val and test input | |
Xval = ss_scaler.transform(Xval) | |
Xtest = ss_scaler.transform(Xtest) |
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
# Splitting into train, val and test set -- 80-10-10 split | |
# First, an 80-20 split | |
Xtrain, Xvaltest, ytrain, yvaltest = train_test_split(X, y, test_size = 0.2) | |
# Then split the 20% into half | |
Xval, Xtest, yval, ytest = train_test_split(Xvaltest, yvaltest, test_size = 0.5) |
NewerOlder