a b/Models/Network/DNN.py
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
# Import useful packages
5
import tensorflow as tf
6
7
8
def DNN(Input, keep_prob, weights_1, biases_1, weights_2, biases_2):
9
    '''
10
11
    Args:
12
        Input: The input EEG signals
13
        keep_prob: The Keep probability of Dropout
14
        weights_1: The Weights of first fully-connected layer
15
        biases_1: The biases of first fully-connected layer
16
        weights_2: The Weights of second fully-connected layer
17
        biases_2: The biases of second fully-connected layer
18
19
    Returns:
20
        FC_2: Final prediction of DNN Model
21
        FC_1: Extracted features from the first fully connected layer
22
23
    '''
24
25
    # First fully-connected layer
26
    FC_1 = tf.matmul(Input, weights_1) + biases_1
27
    FC_1 = tf.layers.batch_normalization(FC_1, training=True)
28
    FC_1 = tf.nn.softplus(FC_1)
29
    FC_1 = tf.nn.dropout(FC_1, keep_prob)
30
31
    # Second fully-connected layer
32
    FC_2 = tf.matmul(FC_1, weights_2) + biases_2
33
    FC_2 = tf.nn.softmax(FC_2)
34
35
    return FC_2, FC_1
36