Commit 1424192a authored by Ard Kastrati's avatar Ard Kastrati
Browse files

Revert "Revert "Integrated InceptionTime, created the structure of the...

Revert "Revert "Integrated InceptionTime, created the structure of the project. InceptionTime is not finished.""

This reverts commit 52ee98d7.
parent 52ee98d7
File added
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 2.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
This diff is collapsed.
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/GitLab.iml" filepath="$PROJECT_DIR$/.idea/GitLab.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Inception/InceptionTime" vcs="Git" />
<mapping directory="$PROJECT_DIR$/InceptionTime" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -39,7 +39,7 @@ def run(trainX, trainY):
train(trainloader=trainloader, net=net, optimizer=optimizer, criterion=criterion)
# save our trained model
PATH = './cifar_net.pth'
PATH = '../cifar_net.pth'
torch.save(net.state_dict(), PATH)
def train(trainloader, net, optimizer, criterion, epoch=50):
......@@ -60,7 +60,7 @@ def train(trainloader, net, optimizer, criterion, epoch=50):
# print statistics
running_loss += loss.item()
if i % 200 == 0: # print every 2000 mini-batches
if i % 200 == 0: # print every 200 mini-batches
print('[%d, %5d] loss: %.3f' %
(epoch + 1, i + 1, running_loss / 200))
running_loss = 0.0
......
def run():
print "test"
\ No newline at end of file
InceptionTime @ 470ce144
Subproject commit 470ce144c1ba43b421e72e1d216105db272e513f
File added
......@@ -2,17 +2,21 @@
# let's keep it here to have a clean code on other methods that we try
general_params = {}
CNN_params = {}
InceptionTime_params = {}
"""
Models:
CNN-1: First try: CNN to predict movement towards left or right (prosaccade) with 1 second data.
RNN? Transformers, Attention, etc etc
InceptionTime: The InceptionTime baseline
EEGNet: The other baseline
DeepEye: Our method
"""
# general parameters
general_params['model'] = "CNN-1"
general_params['model'] = "InceptionTime"
general_params['data_path'] = "/Volumes/methlab/ETH_AS/preprocessed2/"
general_params['root_dir'] = "."
# CNN - 1
CNN_params['trainX_variable1'] = "EEGprocue"
......@@ -21,4 +25,14 @@ CNN_params['trainX_filename'] = "EEGprocue"
CNN_params['trainY_variable1'] = "trialinfopro"
CNN_params['trainY_variable2'] = "cues"
CNN_params['trainY_filename'] = "trialinfocuelocked"
\ No newline at end of file
CNN_params['trainY_filename'] = "trialinfocuelocked"
# InceptionTime
InceptionTime_params['trainX_variable1'] = "EEGprocue"
InceptionTime_params['trainX_variable2'] = "data"
InceptionTime_params['trainX_filename'] = "EEGprocue"
InceptionTime_params['trainY_variable1'] = "trialinfopro"
InceptionTime_params['trainY_variable2'] = "cues"
InceptionTime_params['trainY_filename'] = "trialinfocuelocked"
\ No newline at end of file
File added
# -*- coding: utf-8 -*-
"""initial.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1fkaF_D2KuVjhMZg6lTUaX2D--JhOer2_
# 1. Define a Convolutional Neural Network
"""
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.AvgPool2d(2, stride=2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 60)
self.fc3 = nn.Linear(60, 1)
def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
x = self.pool(F.relu(self.conv2(x)))
x = x.view(-1, 16 * 5 * 5)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
net = Net()
"""# 2. Define an optimizer"""
import torch.optim as optim
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0, amsgrad=False)
"""#3. Train the network
"""
from torch.autograd import Variable
def train(epoch=50):
net.train()
tr_loss = 0
# getting the training set
x_train, y_train = Variable(train_x), Variable(train_y)
# getting the validation set
x_val, y_val = Variable(val_x), Variable(val_y)
# converting the data into GPU format
if torch.cuda.is_available():
x_train = x_train.cuda()
y_train = y_train.cuda()
x_val = x_val.cuda()
y_val = y_val.cuda()
# clearing the Gradients of the model parameters
optimizer.zero_grad()
# prediction for training and validation set
output_train = net(x_train)
output_val = net(x_val)
# computing the training and validation loss
loss_train = criterion(output_train, y_train)
loss_val = criterion(output_val, y_val)
train_losses.append(loss_train)
val_losses.append(loss_val)
# computing the updated weights of all the model parameters
loss_train.backward()
optimizer.step()
tr_loss = loss_train.item()
if epoch % 2 == 0:
# printing the validation loss
print('Epoch : ', epoch + 1, '\t', 'loss :', loss_val)
n_epochs = 50
# empty list to store training losses
train_losses = []
# empty list to store validation losses
val_losses = []
# training the model
for epoch in range(n_epochs):
train()
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