151 lines (141 with data), 11.8 kB
B
Mm^4 ã @ s d Z ddlZddlmZ ddlmZ ddlm mZ G dd dej Z
G dd dej ZG dd dej ZG d d
d
ej Z
G dd dej ZdS )
a
Created by Victor Delvigne
ISIA Lab, Faculty of Engineering University of Mons, Mons (Belgium)
victor.delvigne@umons.ac.be
Source: Bashivan, et al."Learning Representations from EEG with Deep Recurrent-Convolutional Neural Networks." International conference on learning representations (2016).
Copyright (C) 2019 - UMons
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
é Nc sB e Zd ZdZe dddd¡dddddf fdd Zd
d Z ZS )ÚBasicCNNaì
Build the Mean Basic model performing a classification with CNN
param input_image: list of EEG image [batch_size, n_window, n_channel, h, w]
param kernel: kernel size used for the convolutional layers
param stride: stride apply during the convolutions
param padding: padding used during the convolutions
param max_kernel: kernel used for the maxpooling steps
param n_classes: number of classes
return x: output of the last layers after the log softmax
é é é )r r )é r é c s t t| ¡ |jd }tj|d|||d| _tjdd|||d| _tjdd|||d| _tjdd|||d| _ t
|¡| _tjdd|||d| _tjdd|||d| _
tjdd|||d| _t
d¡| _tjdd| _t d d
¡| _t d
|¡| _t ¡ | _d S )Nr r )ÚstrideÚpaddingé@ é )r r g à?)Úpi i )Úsuperr Ú__init__ÚshapeÚnnÚConv2dÚconv1Úconv2Úconv3Úconv4Ú MaxPool2dÚpool1Úconv5Úconv6Úconv7ÚpoolÚDropoutÚdropÚLinearÚfc1Úfc2Ú
LogSoftmaxÚmax)ÚselfÚinput_imageÚkernelr r Ú
max_kernelÚ n_classesÚ n_channel)Ú __class__© ú6/home/vdelv/PycharmProjects/EEGLearn_Pytorch/Models.pyr , s
zBasicCNN.__init__c C sð |j d }t | |¡¡}t | |¡¡}t | |¡¡}t | |¡¡}| |¡}t | |¡¡}t | |¡¡}| |¡}t |
|¡¡}| |¡}| |j d |j d d¡}| |¡}| |j d d¡}|
|¡}| |¡}| |¡}|S )Nr r éÿÿÿÿ)r ÚFÚrelur r r r r r r r Úreshaper r r r"