Commit d5277a2d authored by Mirza Cutuk's avatar Mirza Cutuk
Browse files

GROUPWORK_Testing

parent 083bb0a5
......@@ -3,6 +3,7 @@ import dlc_practical_prologue as prologue
from net import *
from train import *
from helper import *
from torch import nn
# ## file that they will run
......@@ -12,21 +13,16 @@ from helper import *
# model = CNN_VGG(200)
mini_batch_size=100
# # # target = 0 if x1 > x2, target = 1 if x1 <= x2
# train_input, train_target, train_classes, test_input, test_target, test_classes = prologue.generate_pair_sets(1000)
# for _ in range(3):
# model = NN(200)
# train_input, train_target, train_classes, test_input, test_target, test_classes = prologue.generate_pair_sets(1000)
# # print(train_input[0])
# loss_train = train_model_basic(model, train_input, train_target, mini_batch_size, nb_epochs=19)
# errors = compute_nb_errors(model, train_input, train_target, mini_batch_size)
# errors_test, loss_test = compute_nb_errors_test(model, test_input, test_target, mini_batch_size, nb_epochs=19)
# print(f'accuracy of Basic = {100-(errors/10)}')
# print(f'accuracy of Basic, testing = {100-(errors_test/10)}')
# # plt.plot(loss_train)
# # plt.plot(loss_test)
# # plt.legend(['train', 'test'])
# # plt.show()
lr = 1e-4
for _ in range(10):
model = NN(200)
train_input, train_target, train_classes, test_input, test_target, test_classes = prologue.generate_pair_sets(1000)
# print(train_input[0])
loss_train, acc_train = train_model(model, train_input, train_target, lr, nn.BCELoss(), mini_batch_size, nb_epochs=25)
acc_test = test_model(model, test_input, test_target, nn.BCELoss(), mini_batch_size)
print(f' Basic Network train_acc = {acc_train[-1]}')
print(f' Basic Network test_acc = {acc_test}')
# model2 = NN_Classification(200)
......@@ -43,14 +39,16 @@ mini_batch_size=100
# # error_comp = compute_nb_errors_comp(model3, output_class, train_target, mini_batch_size)
# # print(f'accuracy of comparing = {100-(error_comp/10)}')
for _ in range(5):
model_WS = CNN_WS(200)
train_input, train_target, train_classes, test_input, test_target, test_classes = prologue.generate_pair_sets(1000)
train_model_basic(model_WS, train_input, train_target, mini_batch_size, nb_epochs=25)
errors_WS = compute_nb_errors(model_WS, train_input, train_target, mini_batch_size)
errors_WS_test = compute_nb_errors(model_WS, test_input, test_target, mini_batch_size)
print(f'accuracy of Weight Sharing = {100-(errors_WS/10)}')
print(f'accuracy of Weight Sharing, testing = {100-(errors_WS_test/10)}')
# for _ in range(5):
# model_WS = CNN_WS(200)
# train_input, train_target, train_classes, test_input, test_target, test_classes = prologue.generate_pair_sets(1000)
# train_model(model_WS, train_input, train_target, mini_batch_size, nb_epochs=25)
# # errors_WS = compute_nb_errors(model_WS, train_input, train_target, mini_batch_size)
# # errors_WS_test = compute_nb_errors(model_WS, test_input, test_target, mini_batch_size)
# # print(f'accuracy of Weight Sharing = {100-(errors_WS/10)}')
# # print(f'accuracy of Weight Sharing, testing = {100-(errors_WS_test/10)}')
# print(f' train_acc = {acc_train[-1]}')
# print(f' test_acc = {acc_test}')
# for _ in range(5):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment