BrainNetCNN-checkpoint


BrainNetCNN

Software by Amine ECHRAIBI
Internship 2 months IMT Atlantique **Supervisor : Nicolas FARRUGIA version 1

This notebook implements the method described Here and verifies the results.
This is a re-implementation in Keras Tensorflow backend, of the neural net described in the paper.


In [3]:
from __future__ import print_function, division
import matplotlib.pyplot as plt
plt.interactive(False)
import tensorflow as tf
import h5py
from scipy.stats import pearsonr
from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import Dense, Dropout, Flatten
from keras.layers.advanced_activations import LeakyReLU
from keras import optimizers, callbacks, regularizers, initializers
from E2E_conv import *
from injury import ConnectomeInjury
import numpy as np
from vis.visualization import visualize_activation
from keras.utils import to_categorical
from nilearn import datasets
from nilearn import input_data
from nilearn.connectome import ConnectivityMeasure
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score


Using TensorFlow backend.

Setting up the hyper parameters, and l2 regularizer


In [4]:
# Globals : Hyperparamaters
batch_size = 14
dropout = 0.5
momentum = 0.9
noise_weight = 0.0625
lr = 0.01
decay = 0.0005

# Setting l2_norm regularizer
reg = regularizers.l2(decay)
kernel_init = initializers.he_uniform()

Representation of syntheticly generated connectome

Generating data


In [5]:
# Loading synthetic data
injuryconnectome = ConnectomeInjury()
x_train,y_train = injuryconnectome.generate_injury(n_samples=1000,noise_weight=noise_weight)
x_valid,y_valid = injuryconnectome.generate_injury(n_samples=300,noise_weight=noise_weight)

ploting a synthetic connectome


In [6]:
# ploting a sample
%matplotlib inline
plt.imshow(x_train[0][0])
plt.title('synthetic connectome')
plt.show()
print("The adjacency matrix : ")
print(x_train[0][0])


# reshaping data
x_train = x_train.reshape(x_train.shape[0],x_train.shape[3],x_train.shape[2],x_train.shape[1])
x_valid = x_valid.reshape(x_valid.shape[0],x_valid.shape[3],x_valid.shape[2],x_valid.shape[1])


The adjacency matrix : 
[[ 0.01002405  0.0300054   0.16542929 ...,  0.039428    0.01574138
   0.02941762]
 [ 0.0300054   0.00059958  0.02114953 ...,  0.0227737   0.05165235
   0.02692976]
 [ 0.16542929  0.02114953  0.00985316 ...,  0.04477094  0.01872445
   0.04102931]
 ..., 
 [ 0.039428    0.0227737   0.04477094 ...,  0.02803671  0.01934364
   0.16018051]
 [ 0.01574138  0.05165235  0.01872445 ...,  0.01934364  0.02614258
   0.024277  ]
 [ 0.02941762  0.02692976  0.04102931 ...,  0.16018051  0.024277
   0.02903987]]

the synthetic connectome is represented as a graph $G(A,\Omega)$ where :

  • $\Omega$ is the set of nodes each node represents a region of the brain.
  • $ A $ is the weighted adjency matrix of the adges representing the strength of the connections between the regions.

Constructing the new layers

E2E layer

$$ A^{l+1,n}_{i,j} = \sum_{k=1}^{|\Omega|} \sum_{m=1}^{M^{l}}[ r_k^{l,m,n}A_{i,k}^{l,m} + c_k^{l,m,n}A_{k,j}^{l,m}] $$

To construct this layer, we must create two kernels corresponding to r and c of size $1x|\Omega|$ and $|\Omega|x1$ respectively, we then convolve with the output filters, duplicate them $|\Omega|$ times than sum the duplications elementwize to create the convolution discribed above.


In [7]:
# Construction of the Edge-2-Edge layer using Keras backend.
# -*- coding: utf-8 -*-

from keras import backend as K
from keras import activations
from keras import initializers
from keras import regularizers
from keras import constraints
from keras.engine import Layer
from keras.engine import InputSpec
from keras.utils import conv_utils

class E2E_conv(Layer):
    def __init__(self, rank,
                 filters,
                 kernel_size,
                 strides=1,
                 padding='valid',
                 data_format=None,
                 dilation_rate=1,
                 activation=None,
                 use_bias=False,
                 kernel_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 kernel_regularizer=None,
                 bias_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 bias_constraint=None,
                 **kwargs):
        super(E2E_conv, self).__init__(**kwargs)
        self.rank = rank
        self.filters = filters
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, rank, 'kernel_size')
        self.strides = conv_utils.normalize_tuple(strides, rank, 'strides')
        self.padding = conv_utils.normalize_padding(padding)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.dilation_rate = conv_utils.normalize_tuple(dilation_rate, rank, 'dilation_rate')
        self.activation = activations.get(activation)
        self.use_bias = use_bias
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.input_spec = InputSpec(ndim=self.rank + 2)

    def build(self, input_shape):
        if self.data_format == 'channels_first':
            channel_axis = 1
        else:
            channel_axis = -1
        if input_shape[channel_axis] is None:
            raise ValueError('The channel dimension of the inputs '
                             'should be defined. Found `None`.')
        input_dim = input_shape[channel_axis]
        kernel_shape = self.kernel_size + (input_dim, self.filters)

        self.kernel = self.add_weight(shape=kernel_shape,
                                      initializer=self.kernel_initializer,
                                      name='kernel',
                                      regularizer=self.kernel_regularizer,
                                      constraint=self.kernel_constraint)
        if self.use_bias:
            self.bias = self.add_weight(shape=(self.filters,),
                                        initializer=self.bias_initializer,
                                        name='bias',
                                        regularizer=self.bias_regularizer,
                                        constraint=self.bias_constraint)
        else:
            self.bias = None
        # Set input spec.
        self.input_spec = InputSpec(ndim=self.rank + 2,
                                    axes={channel_axis: input_dim})
        self.built = True

    def call(self, inputs):
        kernel_shape=K.get_value(self.kernel).shape
        d=kernel_shape[1]
        kernel1xd = K.reshape(self.kernel[0,:],(1,kernel_shape[1],kernel_shape[2],kernel_shape[3]))
        kerneldx1 = K.reshape(self.kernel[1,:], (kernel_shape[1],1, kernel_shape[2], kernel_shape[3]))
        conv1xd = K.conv2d(
            inputs,
            kernel1xd,
            strides=self.strides,
            padding=self.padding,
            data_format=self.data_format,
            dilation_rate=self.dilation_rate)
        convdx1 = K.conv2d(
                inputs,
                kerneldx1,
                strides=self.strides,
                padding=self.padding,
                data_format=self.data_format,
                dilation_rate=self.dilation_rate)
        concat1 = K.concatenate([convdx1]*d,axis=1)
        concat2 = K.concatenate([conv1xd]*d,axis=2)
        return concat1+concat2

    def compute_output_shape(self, input_shape):
        return (input_shape[0],input_shape[1],input_shape[2],self.filters)

    def get_config(self):
        config = {
            'rank': self.rank,
            'filters': self.filters,
            'kernel_size': self.kernel_size,
            'strides': self.strides,
            'padding': self.padding,
            'data_format': self.data_format,
            'dilation_rate': self.dilation_rate,
            'activation': activations.serialize(self.activation),
            'use_bias': self.use_bias,
            'kernel_initializer': initializers.serialize(self.kernel_initializer),
            'bias_initializer': initializers.serialize(self.bias_initializer),
            'kernel_regularizer': regularizers.serialize(self.kernel_regularizer),
            'bias_regularizer': regularizers.serialize(self.bias_regularizer),
            'activity_regularizer': regularizers.serialize(self.activity_regularizer),
            'kernel_constraint': constraints.serialize(self.kernel_constraint),
            'bias_constraint': constraints.serialize(self.bias_constraint)
        }
        base_config = super(E2E_conv, self).get_config()
        return dict(list(base_config.items()) + list(config.items()))

N.b. the previous cell is here to show how the E2E layer was implemented as a keras layer.

To use the layer, simply do:


In [8]:
from E2E_conv import *

E2N layer

$$a^{l+1,n}_i = \sum_{k=1}^{|\Omega|} \sum_{m=1}^{M^{l}}[ r_k^{l,m,n}A_{i,k}^{l,m} + c_k^{l,m,n}A_{k,i}^{l,m}]$$

A simple 1-D convolution. Code in model architecture

E2N layer

$$ a^{l+1,n} = \sum_{k=1}^{|\Omega|} \sum_{m=1}^{M^{l}} w_k^{l,m,n}a_{i}^{l,m}$$

A simple 1-D convolution. Code in model architecture

Creating the model

Description :

l2_regularization was introduced in every layer. Dropout of 0.5 was introduced for every layer after N2G layer. The Activation uses very leaky rectified linear units '$\alpha=0.33$'.


In [9]:
# Model architecture 

model = Sequential()
model.add(E2E_conv(2,32,(2,90),kernel_regularizer=reg,input_shape=(90,90,1),input_dtype='float32',data_format="channels_last"))
print("First layer output shape :"+str(model.output_shape))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(E2E_conv(2,32,(2,90),kernel_regularizer=reg,data_format="channels_last"))
print(model.output_shape)
model.add(LeakyReLU(alpha=0.33))
model.add(Convolution2D(64,(1,90),kernel_regularizer=reg,data_format="channels_last"))
model.add(LeakyReLU(alpha=0.33))
model.add(Convolution2D(256,(90,1),kernel_regularizer=reg,data_format="channels_last"))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(128,kernel_regularizer=reg,kernel_initializer=kernel_init))
#print(model.output_shape)
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(30,kernel_regularizer=reg,kernel_initializer=kernel_init))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(2,kernel_regularizer=reg,kernel_initializer=kernel_init))
model.add(Flatten())
model.add(LeakyReLU(alpha=0.33))
model.summary()
#print(model.output_shape)


kernel_shape : (2, 90, 1, 32)
data shape : (?, 90, 90, 1)
(1, 90, 1, 32)
(90, 1, 1, 32)
cat1(?, 90, 90, 32)
cat2<dtype: 'float32'>
First layer output shape :(None, 90, 90, 32)
kernel_shape : (2, 90, 32, 32)
data shape : (?, 90, 90, 32)
(1, 90, 32, 32)
(90, 1, 32, 32)
cat1(?, 90, 90, 32)
cat2<dtype: 'float32'>
(None, 90, 90, 32)
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
e2e_conv_1 (E2E_conv)        (None, 90, 90, 32)        5760      
_________________________________________________________________
leaky_re_lu_1 (LeakyReLU)    (None, 90, 90, 32)        0         
_________________________________________________________________
e2e_conv_2 (E2E_conv)        (None, 90, 90, 32)        184320    
_________________________________________________________________
leaky_re_lu_2 (LeakyReLU)    (None, 90, 90, 32)        0         
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 90, 1, 64)         184384    
_________________________________________________________________
leaky_re_lu_3 (LeakyReLU)    (None, 90, 1, 64)         0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 1, 1, 256)         1474816   
_________________________________________________________________
leaky_re_lu_4 (LeakyReLU)    (None, 1, 1, 256)         0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 1, 1, 256)         0         
_________________________________________________________________
dense_1 (Dense)              (None, 1, 1, 128)         32896     
_________________________________________________________________
leaky_re_lu_5 (LeakyReLU)    (None, 1, 1, 128)         0         
_________________________________________________________________
dropout_2 (Dropout)          (None, 1, 1, 128)         0         
_________________________________________________________________
dense_2 (Dense)              (None, 1, 1, 30)          3870      
_________________________________________________________________
leaky_re_lu_6 (LeakyReLU)    (None, 1, 1, 30)          0         
_________________________________________________________________
dropout_3 (Dropout)          (None, 1, 1, 30)          0         
_________________________________________________________________
dense_3 (Dense)              (None, 1, 1, 2)           62        
_________________________________________________________________
flatten_1 (Flatten)          (None, 2)                 0         
_________________________________________________________________
leaky_re_lu_7 (LeakyReLU)    (None, 2)                 0         
=================================================================
Total params: 1,886,108
Trainable params: 1,886,108
Non-trainable params: 0
_________________________________________________________________

Training The model

  • We use the euclidean distance as a cost function
  • The evaluation metric is the mean absolute error

Generating the results


In [10]:
from injury import ConnectomeInjury
from scipy.stats import pearsonr
from sklearn.metrics import mean_absolute_error as mae
from numpy import std
from IPython.display import HTML, display
import tabulate

def generate_synthetic_validation_data(noise):
    injury = ConnectomeInjury() # Generate train/test synthetic data.
    x_valid_y_valid = injury.generate_injury(n_samples=300, noise_weight=noise)
    return x_valid_y_valid


def get_results_from_models(model,noises):
    results = [["noises"]+noises,
               ["mae_alpha"],
               ["stdae_alpha"],
               ["mae_beta"],
               ["stdae_beta"],
               ["r_alpha"],
               ["r_beta"]]
    for i in range(len(noises)):
        noise = noises[i]
        x_valid, y_valid = generate_synthetic_validation_data(noise)
        x_valid = x_valid.reshape(x_valid.shape[0], x_valid.shape[3], x_valid.shape[2], x_valid.shape[1])
        # load weights into new model
        model.load_weights("Weights/BrainCNNWeights_noise_"+str(noise)+".h5")
        print("Loaded model from disk")
        preds = model.predict(x_valid)
        results[1].append("{0:.2f}".format(100*mae(preds[:,0],y_valid[:,0])))
        results[2].append("{0:.2f}".format(100*std(abs(y_valid[:, 0] - preds[:, 0]))))
        results[3].append("{0:.2f}".format(100*mae(preds[:, 1], y_valid[:, 1])))
        results[4].append("{0:.2f}".format(100*std(abs(y_valid[:,1]-preds[:,1]))))
        results[5].append("{0:.2f}".format(pearsonr(preds[:,0],y_valid[:,0])[0]))
        results[6].append("{0:.2f}".format(pearsonr(preds[:, 1], y_valid[:, 1])[0]))
    display(HTML(tabulate.tabulate(results, tablefmt='html')))

Main function

can be run in two modes the training mode where we train the model on the genrated data above (set the desired noise weight above), or the predicting mode where we run our generated trained model on different noise weights and display the results.


In [13]:
opt = optimizers.SGD(momentum=momentum,nesterov=True,lr=lr)
model.compile(optimizer=opt,loss='mean_squared_error',metrics=['mae'])
csv_logger = callbacks.CSVLogger('BrainCNN.log')
command = str(raw_input("Train or predict ? [t/p] "))
if command == "t":
    print("Training for noise = "+str(noise_weight))
    history=model.fit(x_train,y_train,nb_epoch=1000,verbose=1,callbacks=[csv_logger])
    model.save_weights("Weights/BrainCNNWeights_noise_"+str(noise_weight)+".h5")
else:
    print("[*] Predicting and printing results for the models trained :")
    get_results_from_models(model,noises = [0,0.0625,0.125,0.25])


Train or predict ? [t/p] p
[*] Predicting and printing results for the models trained :
Loaded model from disk
Loaded model from disk
Loaded model from disk
Loaded model from disk
noises 0 0.06250.125 0.25
mae_alpha 3.675.26 9.69 17.36
stdae_alpha2.474.04 7.44 12.6
mae_beta 2.315.58 9.63 16.91
stdae_beta 1.654.18 6.89 12.33
r_alpha 1 0.97 0.88 0.58
r_beta 1 0.97 0.89 0.6

the table above describes the results of the mean absolute error, standard deviation absolute error, and correlation for each of the parameters alpha and beta for different levels of noise.

Conclusion:

The table above verifies the results described in the paper.

Verifying the visualization methode using Keras-vis "Activation-Maximization"

generating synthetic data

The functions bellow generate synthetic connectomes with injuries introduced at a specific region, the injury affects all the connections spreading from the region with different intensities. The code bellow is a modification of the opensource implementation using Caffe described Here


In [11]:
# generating injury signitures S_1 ans S_2

def get_symmetric_noise(m, n):
    """Return a random noise image of size m x n with values between 0 and 1."""

    # Generate random noise image.
    noise_img = np.random.rand(m, n)

    # Make the noise image symmetric.
    noise_img = noise_img + noise_img.T

    # Normalize between 0 and 1.
    noise_img = (noise_img - noise_img.min()) / (noise_img.max() - noise_img.min())

    assert noise_img.max() == 1  # Make sure is between 0 and 1.
    assert noise_img.min() == 0
    assert (noise_img.T == noise_img).all()  # Make sure symmetric.

    return noise_img

def simulate_injury(X, weight_A, sig_A):
    denom = (np.ones(X.shape) + (weight_A * sig_A))
    X_sig_AB = np.divide(X, denom)
    return X_sig_AB

def apply_injury_and_noise(X, Sig_A, weight_A,noise_weight):
    """Returns a symmetric, signed, noisy, adjacency matrix with simulated injury from two sources."""
    X_sig_AB = simulate_injury(X, weight_A, Sig_A)
    # Get the noise image.
    noise_img = get_symmetric_noise(X.shape[0], X.shape[1])

    # Weight the noise image.
    weighted_noise_img = noise_img * noise_weight

    # Add the noise to the original image.
    X_sig_AB_noise = X_sig_AB + weighted_noise_img
    

    assert (X_sig_AB_noise[0,:,:].T == X_sig_AB_noise[0,:,:]).all()  # Make sure still is symmetric.

    return X_sig_AB_noise


def generate_injury_signatures(X_mn, r_state,sig_indexes):
        """Generates the signatures that represent the underlying signal in our synthetic experiments.

        d : (integer) the size of the input matrix (assumes is size dxd)
        """

        # Get the strongest regions, which we will apply simulated injuries
        sig_indexes = sig_indexes
        d = X_mn.shape[0]

        S = []

        # Create a signature for
        for idx, sig_idx in enumerate(sig_indexes):
            # Okay, let's make some signature noise vectors.
            A_vec = r_state.rand((d))
            # B_vec = np.random.random((n))

            # Create the signature matrix.
            A = np.zeros((d, d))
            A[:, sig_idx] = A_vec
            A[sig_idx, :] = A_vec
            S.append(A)
            
            assert (A.T == A).all()  # Check if matrix is symmetric.

        return np.asarray(S)
def sample_injury_strengths(n_samples, X_mn, A, noise_weight):
        """Returns n_samples connectomes with simulated injury from two sources."""
        mult_factor = 10

        n_classes = 1

        # Range of values to predict.
        n_start = 0.5
        n_end = 1.4
        # amt_increase = 0.1

        # These will be our Y.
        A_weights = np.random.uniform(n_start, n_end, [n_samples])

        X_h5 = np.zeros((n_samples, 1, X_mn.shape[0], X_mn.shape[1]), dtype=np.float32)
        Y_h5 = np.zeros((n_samples, n_classes), dtype=np.float32)

        for idx in range(n_samples):
            w_A = A_weights[idx]

            # Get the matrix.
            X_sig = apply_injury_and_noise(X_mn, A, w_A * mult_factor, noise_weight)

            # Normalize.
            X_sig = (X_sig - X_sig.min()) / (X_sig.max() - X_sig.min())

            # Put in h5 format.
            X_h5[idx, 0, :, :] = X_sig
            Y_h5[idx, :] = [w_A]

        return X_h5, Y_h5
    
def load_base_connectome():
    X_mn = scipy.io.loadmat("data/base.mat")
    X_mn = X_mn['X_mn']
    return X_mn

Using Adhd data for visualization

in this section we will use adhd data collected from nilearn database to construct a mean connectome of the control patients, than we will use this mean connectome to generate the phantom dataset with injuries introduced at specific regions.

Downloading data


In [12]:
adhd_data = datasets.fetch_adhd(n_subjects=20)
msdl_data = datasets.fetch_atlas_msdl()
msdl_coords = msdl_data.region_coords

masker = input_data.NiftiMapsMasker(
    msdl_data.maps, resampling_target="data", t_r=2.5, detrend=True,
    low_pass=.1, high_pass=.01, memory='nilearn_cache', memory_level=1)
adhd_subjects = []
pooled_subjects = []
site_names = []
adhd_labels = []  # 1 if ADHD, 0 if control
for func_file, confound_file, phenotypic in zip(
        adhd_data.func, adhd_data.confounds, adhd_data.phenotypic):
    time_series = masker.fit_transform(func_file, confounds=confound_file)
    pooled_subjects.append(time_series)
    is_adhd = phenotypic['adhd']
    if is_adhd:
        adhd_subjects.append(time_series)

    site_names.append(phenotypic['site'])
    adhd_labels.append(is_adhd)

conn_measure = ConnectivityMeasure(kind="tangent")
X = conn_measure.fit_transform(pooled_subjects)
Y = np.array(adhd_labels,dtype="float32")

Setting up the network architecture

the phantom data genetated is constructed from the mean connectome of the control patients from adhd dataset, we generate two classes of injuries each at a specific region, than the BrainNetCNN is trained to detect each class. finaly we use keras-vis "maximization-activation" to genrate connectomes maximizing the classification score.


In [50]:
# Hyper parameters

batch_size = 14
dropout = 0.5
momentum = 0.9
lr = 0.001
decay = 0.0005
noise_weight = 0.0625

reg = regularizers.l2(decay)
kernel_init = initializers.he_uniform()

# Model architecture


model = Sequential()
model.add(E2E_conv(2,8,(2,39),kernel_regularizer=reg,input_shape=(39,39,1),input_dtype='float32',data_format="channels_last"))
print("First layer output shape :"+str(model.output_shape))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
print(model.output_shape)
model.add(LeakyReLU(alpha=0.33))
model.add(Convolution2D(3,(1,39),kernel_regularizer=reg,data_format="channels_last"))
model.add(LeakyReLU(alpha=0.33))
model.add(Convolution2D(90,(39,1),kernel_regularizer=reg,data_format="channels_last"))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(64,kernel_regularizer=reg,kernel_initializer=kernel_init))
#print(model.output_shape)
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(10,kernel_regularizer=reg,kernel_initializer=kernel_init))
model.add(LeakyReLU(alpha=0.33))
#print(model.output_shape)
model.add(Dropout(0.5))
model.add(Dense(2,activation = "softmax",kernel_regularizer=reg,kernel_initializer=kernel_init))
model.add(Flatten())
model.summary()
#print(model.output_shape)


opt = optimizers.SGD(nesterov=True,lr=lr)
model.compile(optimizer=opt,loss='binary_crossentropy',metrics=['accuracy'])
csv_logger = callbacks.CSVLogger('predict_age.log')


kernel_shape : (2, 39, 1, 8)
data shape : (?, 39, 39, 1)
(1, 39, 1, 8)
(39, 1, 1, 8)
cat1(?, 39, 39, 8)
cat2<dtype: 'float32'>
First layer output shape :(None, 39, 39, 8)
(None, 39, 39, 8)
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
e2e_conv_4 (E2E_conv)        (None, 39, 39, 8)         624       
_________________________________________________________________
leaky_re_lu_14 (LeakyReLU)   (None, 39, 39, 8)         0         
_________________________________________________________________
leaky_re_lu_15 (LeakyReLU)   (None, 39, 39, 8)         0         
_________________________________________________________________
conv2d_5 (Conv2D)            (None, 39, 1, 3)          939       
_________________________________________________________________
leaky_re_lu_16 (LeakyReLU)   (None, 39, 1, 3)          0         
_________________________________________________________________
conv2d_6 (Conv2D)            (None, 1, 1, 90)          10620     
_________________________________________________________________
leaky_re_lu_17 (LeakyReLU)   (None, 1, 1, 90)          0         
_________________________________________________________________
dropout_7 (Dropout)          (None, 1, 1, 90)          0         
_________________________________________________________________
dense_7 (Dense)              (None, 1, 1, 64)          5824      
_________________________________________________________________
leaky_re_lu_18 (LeakyReLU)   (None, 1, 1, 64)          0         
_________________________________________________________________
dropout_8 (Dropout)          (None, 1, 1, 64)          0         
_________________________________________________________________
dense_8 (Dense)              (None, 1, 1, 10)          650       
_________________________________________________________________
leaky_re_lu_19 (LeakyReLU)   (None, 1, 1, 10)          0         
_________________________________________________________________
dropout_9 (Dropout)          (None, 1, 1, 10)          0         
_________________________________________________________________
dense_9 (Dense)              (None, 1, 1, 2)           22        
_________________________________________________________________
flatten_3 (Flatten)          (None, 2)                 0         
=================================================================
Total params: 18,679
Trainable params: 18,679
Non-trainable params: 0
_________________________________________________________________

In [14]:
# Generating the two classes injury introduced at node 5 and 30
control = X[Y==0]
r_state = np.random.RandomState(41)
base_connectome = control.mean(axis=0)
base_connectome = (base_connectome.T + base_connectome)/2
S = generate_injury_signatures(X_mn=base_connectome,r_state=r_state,sig_indexes=[5])
X1,Y = sample_injury_strengths(1000,base_connectome,S,noise_weight)
S = generate_injury_signatures(X_mn=base_connectome,r_state=r_state,sig_indexes=[30])
X2,Y = sample_injury_strengths(1000,base_connectome,S,noise_weight)

In [15]:
# Constructing the dataset
X = np.concatenate([X1,X2],axis=0)
X = X.reshape(X.shape[0],X.shape[2],X.shape[3],1)
Y1 = np.array([1]*1000)
Y2 = np.array([0]*1000)
Y = np.concatenate([Y1,Y2],axis=0)
Y = to_categorical(Y,2)
x_train,x_test,y_train,y_test = train_test_split(X,Y,test_size=0.33,random_state=42)

In [51]:
# fitting the model 
train = str(raw_input("train/predict enter 1/0"))
if train =="1" :
    model.fit(x_train,y_train,batch_size=14,nb_epoch=1000,verbose=1,callbacks=[csv_logger])
    model.save_weights("Weights/BrainCNNWeights_Visualization.h5")
else :
    model.load_weights("Weights/BrainCNNWeights_Visualization.h5")
    evals = model.evaluate(batch_size=14,x=x_test,y=y_test)
    print(evals)


train/predict enter 1/01
/home/amine/.local/lib/python2.7/site-packages/keras/models.py:851: UserWarning: The `nb_epoch` argument in `fit` has been renamed `epochs`.
  warnings.warn('The `nb_epoch` argument in `fit` '
Epoch 1/1000
1340/1340 [==============================] - 0s - loss: 0.7748 - acc: 0.5030     
Epoch 2/1000
1340/1340 [==============================] - 0s - loss: 0.7760 - acc: 0.4866     
Epoch 3/1000
1340/1340 [==============================] - 0s - loss: 0.7748 - acc: 0.4985     
Epoch 4/1000
1340/1340 [==============================] - 0s - loss: 0.7739 - acc: 0.5187     
Epoch 5/1000
1340/1340 [==============================] - 0s - loss: 0.7744 - acc: 0.5164     
Epoch 6/1000
1340/1340 [==============================] - 0s - loss: 0.7758 - acc: 0.4978     
Epoch 7/1000
1340/1340 [==============================] - 0s - loss: 0.7733 - acc: 0.5239     
Epoch 8/1000
1340/1340 [==============================] - 0s - loss: 0.7742 - acc: 0.5090     
Epoch 9/1000
1340/1340 [==============================] - 0s - loss: 0.7742 - acc: 0.4993     
Epoch 10/1000
1340/1340 [==============================] - 0s - loss: 0.7754 - acc: 0.5082     
Epoch 11/1000
1340/1340 [==============================] - 0s - loss: 0.7736 - acc: 0.5261     
Epoch 12/1000
1340/1340 [==============================] - 0s - loss: 0.7736 - acc: 0.5351     
Epoch 13/1000
1340/1340 [==============================] - 0s - loss: 0.7733 - acc: 0.5261     
Epoch 14/1000
1340/1340 [==============================] - 0s - loss: 0.7729 - acc: 0.5269     
Epoch 15/1000
1340/1340 [==============================] - 0s - loss: 0.7726 - acc: 0.5246     
Epoch 16/1000
1340/1340 [==============================] - 0s - loss: 0.7738 - acc: 0.5067     
Epoch 17/1000
1340/1340 [==============================] - 0s - loss: 0.7721 - acc: 0.5366     
Epoch 18/1000
1340/1340 [==============================] - 0s - loss: 0.7721 - acc: 0.5164     
Epoch 19/1000
1340/1340 [==============================] - 0s - loss: 0.7713 - acc: 0.5396     
Epoch 20/1000
1340/1340 [==============================] - 0s - loss: 0.7710 - acc: 0.5425     
Epoch 21/1000
1340/1340 [==============================] - 0s - loss: 0.7703 - acc: 0.5657     
Epoch 22/1000
1340/1340 [==============================] - 0s - loss: 0.7694 - acc: 0.5530     
Epoch 23/1000
1340/1340 [==============================] - 0s - loss: 0.7701 - acc: 0.5455     
Epoch 24/1000
1340/1340 [==============================] - 0s - loss: 0.7681 - acc: 0.5851     
Epoch 25/1000
1340/1340 [==============================] - 0s - loss: 0.7685 - acc: 0.5597     
Epoch 26/1000
1340/1340 [==============================] - 0s - loss: 0.7679 - acc: 0.5769     
Epoch 27/1000
1340/1340 [==============================] - 0s - loss: 0.7672 - acc: 0.5821     
Epoch 28/1000
1340/1340 [==============================] - 0s - loss: 0.7642 - acc: 0.5679     
Epoch 29/1000
1340/1340 [==============================] - 0s - loss: 0.7655 - acc: 0.6045     
Epoch 30/1000
1340/1340 [==============================] - 0s - loss: 0.7627 - acc: 0.6343     
Epoch 31/1000
1340/1340 [==============================] - 0s - loss: 0.7604 - acc: 0.6567     
Epoch 32/1000
1340/1340 [==============================] - 0s - loss: 0.7582 - acc: 0.6612     
Epoch 33/1000
1340/1340 [==============================] - 0s - loss: 0.7586 - acc: 0.6634     
Epoch 34/1000
1340/1340 [==============================] - 0s - loss: 0.7551 - acc: 0.6873     
Epoch 35/1000
1340/1340 [==============================] - 0s - loss: 0.7517 - acc: 0.6784     
Epoch 36/1000
1340/1340 [==============================] - 0s - loss: 0.7486 - acc: 0.6881     
Epoch 37/1000
1340/1340 [==============================] - 0s - loss: 0.7443 - acc: 0.7149     
Epoch 38/1000
1340/1340 [==============================] - 0s - loss: 0.7418 - acc: 0.7321     
Epoch 39/1000
1340/1340 [==============================] - 0s - loss: 0.7378 - acc: 0.7246     
Epoch 40/1000
1340/1340 [==============================] - 0s - loss: 0.7321 - acc: 0.7388     
Epoch 41/1000
1340/1340 [==============================] - 0s - loss: 0.7261 - acc: 0.7545     
Epoch 42/1000
1340/1340 [==============================] - 0s - loss: 0.7246 - acc: 0.7433     
Epoch 43/1000
1340/1340 [==============================] - 0s - loss: 0.7168 - acc: 0.7716     
Epoch 44/1000
1340/1340 [==============================] - 0s - loss: 0.7082 - acc: 0.7858     
Epoch 45/1000
1340/1340 [==============================] - 0s - loss: 0.6996 - acc: 0.7851     
Epoch 46/1000
1340/1340 [==============================] - 0s - loss: 0.6891 - acc: 0.8015     
Epoch 47/1000
1340/1340 [==============================] - 0s - loss: 0.6810 - acc: 0.8209     
Epoch 48/1000
1340/1340 [==============================] - 0s - loss: 0.6635 - acc: 0.8433     
Epoch 49/1000
1340/1340 [==============================] - 0s - loss: 0.6504 - acc: 0.8470     
Epoch 50/1000
1340/1340 [==============================] - 0s - loss: 0.6377 - acc: 0.8515     
Epoch 51/1000
1340/1340 [==============================] - 0s - loss: 0.6289 - acc: 0.8619     
Epoch 52/1000
1340/1340 [==============================] - 0s - loss: 0.6004 - acc: 0.8843     
Epoch 53/1000
1340/1340 [==============================] - 0s - loss: 0.5908 - acc: 0.8776     
Epoch 54/1000
1340/1340 [==============================] - 0s - loss: 0.5683 - acc: 0.8881     
Epoch 55/1000
1340/1340 [==============================] - 0s - loss: 0.5441 - acc: 0.9090     
Epoch 56/1000
1340/1340 [==============================] - 0s - loss: 0.5160 - acc: 0.9179     
Epoch 57/1000
1340/1340 [==============================] - 0s - loss: 0.5031 - acc: 0.9104     
Epoch 58/1000
1340/1340 [==============================] - 0s - loss: 0.4824 - acc: 0.9358     
Epoch 59/1000
1340/1340 [==============================] - 0s - loss: 0.4578 - acc: 0.9410     
Epoch 60/1000
1340/1340 [==============================] - 0s - loss: 0.4425 - acc: 0.9493     
Epoch 61/1000
1340/1340 [==============================] - 0s - loss: 0.4251 - acc: 0.9418     
Epoch 62/1000
1340/1340 [==============================] - 0s - loss: 0.4079 - acc: 0.9560     
Epoch 63/1000
1340/1340 [==============================] - 0s - loss: 0.3933 - acc: 0.9664     
Epoch 64/1000
1340/1340 [==============================] - 0s - loss: 0.3755 - acc: 0.9597     
Epoch 65/1000
1340/1340 [==============================] - 0s - loss: 0.3599 - acc: 0.9575     
Epoch 66/1000
1340/1340 [==============================] - 0s - loss: 0.3482 - acc: 0.9590     
Epoch 67/1000
1340/1340 [==============================] - 0s - loss: 0.3323 - acc: 0.9664     
Epoch 68/1000
1340/1340 [==============================] - 0s - loss: 0.3090 - acc: 0.9754     
Epoch 69/1000
1340/1340 [==============================] - 0s - loss: 0.3068 - acc: 0.9701     
Epoch 70/1000
1340/1340 [==============================] - 0s - loss: 0.2943 - acc: 0.9709     
Epoch 71/1000
1340/1340 [==============================] - 0s - loss: 0.2878 - acc: 0.9642     
Epoch 72/1000
1340/1340 [==============================] - 0s - loss: 0.2810 - acc: 0.9769     
Epoch 73/1000
1340/1340 [==============================] - 0s - loss: 0.2713 - acc: 0.9754     
Epoch 74/1000
1340/1340 [==============================] - 0s - loss: 0.2504 - acc: 0.9813     
Epoch 75/1000
1340/1340 [==============================] - 0s - loss: 0.2532 - acc: 0.9776     
Epoch 76/1000
1340/1340 [==============================] - 0s - loss: 0.2461 - acc: 0.9799     
Epoch 77/1000
1340/1340 [==============================] - 0s - loss: 0.2341 - acc: 0.9836     
Epoch 78/1000
1340/1340 [==============================] - 0s - loss: 0.2383 - acc: 0.9784     
Epoch 79/1000
1340/1340 [==============================] - 0s - loss: 0.2299 - acc: 0.9836     
Epoch 80/1000
1340/1340 [==============================] - 0s - loss: 0.2165 - acc: 0.9836     
Epoch 81/1000
1340/1340 [==============================] - 0s - loss: 0.2165 - acc: 0.9828     
Epoch 82/1000
1340/1340 [==============================] - 0s - loss: 0.2164 - acc: 0.9746     
Epoch 83/1000
1340/1340 [==============================] - 0s - loss: 0.2024 - acc: 0.9858     
Epoch 84/1000
1340/1340 [==============================] - 0s - loss: 0.1986 - acc: 0.9888     
Epoch 85/1000
1340/1340 [==============================] - 0s - loss: 0.1968 - acc: 0.9843     
Epoch 86/1000
1340/1340 [==============================] - 0s - loss: 0.1887 - acc: 0.9821     
Epoch 87/1000
1340/1340 [==============================] - 0s - loss: 0.1906 - acc: 0.9821     
Epoch 88/1000
1340/1340 [==============================] - 0s - loss: 0.1797 - acc: 0.9851     
Epoch 89/1000
1340/1340 [==============================] - 0s - loss: 0.1795 - acc: 0.9828     
Epoch 90/1000
1340/1340 [==============================] - 0s - loss: 0.1751 - acc: 0.9881     
Epoch 91/1000
1340/1340 [==============================] - 0s - loss: 0.1706 - acc: 0.9888     
Epoch 92/1000
1340/1340 [==============================] - 0s - loss: 0.1682 - acc: 0.9873     
Epoch 93/1000
1340/1340 [==============================] - 0s - loss: 0.1707 - acc: 0.9896     
Epoch 94/1000
1340/1340 [==============================] - 0s - loss: 0.1596 - acc: 0.9918     
Epoch 95/1000
1340/1340 [==============================] - 0s - loss: 0.1642 - acc: 0.9843     
Epoch 96/1000
1340/1340 [==============================] - 0s - loss: 0.1619 - acc: 0.9866     
Epoch 97/1000
1340/1340 [==============================] - 0s - loss: 0.1572 - acc: 0.9881     
Epoch 98/1000
1340/1340 [==============================] - 0s - loss: 0.1527 - acc: 0.9918     
Epoch 99/1000
1340/1340 [==============================] - 0s - loss: 0.1553 - acc: 0.9918     
Epoch 100/1000
1340/1340 [==============================] - 0s - loss: 0.1528 - acc: 0.9896     
Epoch 101/1000
1340/1340 [==============================] - 0s - loss: 0.1492 - acc: 0.9873     
Epoch 102/1000
1340/1340 [==============================] - 0s - loss: 0.1509 - acc: 0.9910     
Epoch 103/1000
1340/1340 [==============================] - 0s - loss: 0.1427 - acc: 0.9955     
Epoch 104/1000
1340/1340 [==============================] - 0s - loss: 0.1488 - acc: 0.9851     
Epoch 105/1000
1340/1340 [==============================] - 0s - loss: 0.1398 - acc: 0.9888     
Epoch 106/1000
1340/1340 [==============================] - 0s - loss: 0.1402 - acc: 0.9910     
Epoch 107/1000
1340/1340 [==============================] - 0s - loss: 0.1423 - acc: 0.9821     
Epoch 108/1000
1340/1340 [==============================] - 0s - loss: 0.1409 - acc: 0.9933     
Epoch 109/1000
1340/1340 [==============================] - 0s - loss: 0.1405 - acc: 0.9925     
Epoch 110/1000
1340/1340 [==============================] - 0s - loss: 0.1391 - acc: 0.9888     
Epoch 111/1000
1340/1340 [==============================] - 0s - loss: 0.1352 - acc: 0.9918     
Epoch 112/1000
1340/1340 [==============================] - 0s - loss: 0.1381 - acc: 0.9910     
Epoch 113/1000
1340/1340 [==============================] - 0s - loss: 0.1442 - acc: 0.9858     
Epoch 114/1000
1340/1340 [==============================] - 0s - loss: 0.1397 - acc: 0.9888     
Epoch 115/1000
1340/1340 [==============================] - 0s - loss: 0.1327 - acc: 0.9933     
Epoch 116/1000
1340/1340 [==============================] - 0s - loss: 0.1293 - acc: 0.9948     
Epoch 117/1000
1340/1340 [==============================] - 0s - loss: 0.1298 - acc: 0.9925     
Epoch 118/1000
1340/1340 [==============================] - 0s - loss: 0.1337 - acc: 0.9873     
Epoch 119/1000
1340/1340 [==============================] - 0s - loss: 0.1335 - acc: 0.9910     
Epoch 120/1000
1340/1340 [==============================] - 0s - loss: 0.1251 - acc: 0.9955     
Epoch 121/1000
1340/1340 [==============================] - 0s - loss: 0.1260 - acc: 0.9925     
Epoch 122/1000
1340/1340 [==============================] - 0s - loss: 0.1265 - acc: 0.9940     
Epoch 123/1000
1340/1340 [==============================] - 0s - loss: 0.1224 - acc: 0.9955     
Epoch 124/1000
1340/1340 [==============================] - 0s - loss: 0.1287 - acc: 0.9896     
Epoch 125/1000
1340/1340 [==============================] - 0s - loss: 0.1219 - acc: 0.9933     
Epoch 126/1000
1340/1340 [==============================] - 0s - loss: 0.1222 - acc: 0.9940     
Epoch 127/1000
1340/1340 [==============================] - 0s - loss: 0.1215 - acc: 0.9918     
Epoch 128/1000
1340/1340 [==============================] - 0s - loss: 0.1238 - acc: 0.9896     
Epoch 129/1000
1340/1340 [==============================] - 0s - loss: 0.1226 - acc: 0.9903     
Epoch 130/1000
1340/1340 [==============================] - 0s - loss: 0.1185 - acc: 0.9963     
Epoch 131/1000
1340/1340 [==============================] - 0s - loss: 0.1170 - acc: 0.9948     
Epoch 132/1000
1340/1340 [==============================] - 0s - loss: 0.1191 - acc: 0.9948     
Epoch 133/1000
1340/1340 [==============================] - 0s - loss: 0.1185 - acc: 0.9918     
Epoch 134/1000
1340/1340 [==============================] - 0s - loss: 0.1223 - acc: 0.9925     
Epoch 135/1000
1340/1340 [==============================] - 0s - loss: 0.1181 - acc: 0.9918     
Epoch 136/1000
1340/1340 [==============================] - 0s - loss: 0.1162 - acc: 0.9955     
Epoch 137/1000
1340/1340 [==============================] - 0s - loss: 0.1188 - acc: 0.9940     
Epoch 138/1000
1340/1340 [==============================] - 0s - loss: 0.1217 - acc: 0.9903     
Epoch 139/1000
1340/1340 [==============================] - 0s - loss: 0.1138 - acc: 0.9970     
Epoch 140/1000
1340/1340 [==============================] - 0s - loss: 0.1101 - acc: 0.9970     
Epoch 141/1000
1340/1340 [==============================] - 0s - loss: 0.1114 - acc: 0.9970     
Epoch 142/1000
1340/1340 [==============================] - 0s - loss: 0.1117 - acc: 0.9940     
Epoch 143/1000
1340/1340 [==============================] - 0s - loss: 0.1123 - acc: 0.9940     
Epoch 144/1000
1340/1340 [==============================] - 0s - loss: 0.1186 - acc: 0.9910     
Epoch 145/1000
1340/1340 [==============================] - 0s - loss: 0.1115 - acc: 0.9955     
Epoch 146/1000
1340/1340 [==============================] - 0s - loss: 0.1146 - acc: 0.9948     
Epoch 147/1000
1340/1340 [==============================] - 0s - loss: 0.1138 - acc: 0.9925     
Epoch 148/1000
1340/1340 [==============================] - 0s - loss: 0.1107 - acc: 0.9955     
Epoch 149/1000
1340/1340 [==============================] - 0s - loss: 0.1131 - acc: 0.9963     
Epoch 150/1000
1340/1340 [==============================] - 0s - loss: 0.1115 - acc: 0.9955     
Epoch 151/1000
1340/1340 [==============================] - 0s - loss: 0.1094 - acc: 0.9918     
Epoch 152/1000
1340/1340 [==============================] - 0s - loss: 0.1086 - acc: 0.9963     
Epoch 153/1000
1340/1340 [==============================] - 0s - loss: 0.1130 - acc: 0.9925     
Epoch 154/1000
1340/1340 [==============================] - 0s - loss: 0.1128 - acc: 0.9933     
Epoch 155/1000
1340/1340 [==============================] - 0s - loss: 0.1067 - acc: 0.9963     
Epoch 156/1000
1340/1340 [==============================] - 0s - loss: 0.1129 - acc: 0.9955     
Epoch 157/1000
1340/1340 [==============================] - 0s - loss: 0.1145 - acc: 0.9925     
Epoch 158/1000
1340/1340 [==============================] - 0s - loss: 0.1108 - acc: 0.9955     
Epoch 159/1000
1340/1340 [==============================] - 0s - loss: 0.1071 - acc: 0.9948     
Epoch 160/1000
1340/1340 [==============================] - 0s - loss: 0.1059 - acc: 0.9970     
Epoch 161/1000
1340/1340 [==============================] - 0s - loss: 0.1058 - acc: 0.9948     
Epoch 162/1000
1340/1340 [==============================] - 0s - loss: 0.1073 - acc: 0.9940     
Epoch 163/1000
1340/1340 [==============================] - 0s - loss: 0.1079 - acc: 0.9963     
Epoch 164/1000
1340/1340 [==============================] - 0s - loss: 0.1090 - acc: 0.9925     
Epoch 165/1000
1340/1340 [==============================] - 0s - loss: 0.1081 - acc: 0.9948     
Epoch 166/1000
1340/1340 [==============================] - 0s - loss: 0.1068 - acc: 0.9963     
Epoch 167/1000
1340/1340 [==============================] - 0s - loss: 0.1106 - acc: 0.9918     
Epoch 168/1000
1340/1340 [==============================] - 0s - loss: 0.1047 - acc: 0.9970     
Epoch 169/1000
1340/1340 [==============================] - 0s - loss: 0.1041 - acc: 0.9948     
Epoch 170/1000
1340/1340 [==============================] - 0s - loss: 0.1035 - acc: 0.9963     
Epoch 171/1000
1340/1340 [==============================] - 0s - loss: 0.1034 - acc: 0.9963     
Epoch 172/1000
1340/1340 [==============================] - 0s - loss: 0.1060 - acc: 0.9970     
Epoch 173/1000
1340/1340 [==============================] - 0s - loss: 0.1089 - acc: 0.9940     
Epoch 174/1000
1340/1340 [==============================] - 0s - loss: 0.1053 - acc: 0.9978     
Epoch 175/1000
1340/1340 [==============================] - 0s - loss: 0.1077 - acc: 0.9918     
Epoch 176/1000
1340/1340 [==============================] - 0s - loss: 0.1015 - acc: 0.9970     
Epoch 177/1000
1340/1340 [==============================] - 0s - loss: 0.1054 - acc: 0.9948     
Epoch 178/1000
1340/1340 [==============================] - 0s - loss: 0.1044 - acc: 0.9955     
Epoch 179/1000
1340/1340 [==============================] - 0s - loss: 0.1064 - acc: 0.9948     
Epoch 180/1000
1340/1340 [==============================] - 0s - loss: 0.1043 - acc: 0.9963     
Epoch 181/1000
1340/1340 [==============================] - 0s - loss: 0.1026 - acc: 0.9955     
Epoch 182/1000
1340/1340 [==============================] - 0s - loss: 0.1045 - acc: 0.9955     
Epoch 183/1000
1340/1340 [==============================] - 0s - loss: 0.1013 - acc: 0.9970     
Epoch 184/1000
1340/1340 [==============================] - 0s - loss: 0.1036 - acc: 0.9955     
Epoch 185/1000
1340/1340 [==============================] - 0s - loss: 0.1028 - acc: 0.9963     
Epoch 186/1000
1340/1340 [==============================] - 0s - loss: 0.1016 - acc: 0.9970     
Epoch 187/1000
1340/1340 [==============================] - 0s - loss: 0.1024 - acc: 0.9955     
Epoch 188/1000
1340/1340 [==============================] - 0s - loss: 0.1050 - acc: 0.9955     
Epoch 189/1000
1340/1340 [==============================] - 0s - loss: 0.0973 - acc: 0.9985     
Epoch 190/1000
1340/1340 [==============================] - 0s - loss: 0.1039 - acc: 0.9933     
Epoch 191/1000
1340/1340 [==============================] - 0s - loss: 0.1008 - acc: 0.9970     
Epoch 192/1000
1340/1340 [==============================] - 0s - loss: 0.1031 - acc: 0.9978     
Epoch 193/1000
1340/1340 [==============================] - 0s - loss: 0.1023 - acc: 0.9970     
Epoch 194/1000
1340/1340 [==============================] - 0s - loss: 0.1010 - acc: 0.9963     
Epoch 195/1000
1340/1340 [==============================] - 0s - loss: 0.1033 - acc: 0.9940     
Epoch 196/1000
1340/1340 [==============================] - 0s - loss: 0.1000 - acc: 0.9963     
Epoch 197/1000
1340/1340 [==============================] - 0s - loss: 0.0992 - acc: 1.0000     
Epoch 198/1000
1340/1340 [==============================] - 0s - loss: 0.0983 - acc: 0.9978     
Epoch 199/1000
1340/1340 [==============================] - 0s - loss: 0.1005 - acc: 0.9970     
Epoch 200/1000
1340/1340 [==============================] - 0s - loss: 0.0974 - acc: 0.9985     
Epoch 201/1000
1340/1340 [==============================] - 0s - loss: 0.1021 - acc: 0.9948     
Epoch 202/1000
1340/1340 [==============================] - 0s - loss: 0.0959 - acc: 1.0000     
Epoch 203/1000
1340/1340 [==============================] - 0s - loss: 0.1007 - acc: 0.9970     
Epoch 204/1000
1340/1340 [==============================] - 0s - loss: 0.1047 - acc: 0.9940     
Epoch 205/1000
1340/1340 [==============================] - 0s - loss: 0.1005 - acc: 0.9955     
Epoch 206/1000
1340/1340 [==============================] - 0s - loss: 0.0987 - acc: 0.9970     
Epoch 207/1000
1340/1340 [==============================] - 0s - loss: 0.1011 - acc: 0.9970     
Epoch 208/1000
1340/1340 [==============================] - 0s - loss: 0.1016 - acc: 0.9978     
Epoch 209/1000
1340/1340 [==============================] - 0s - loss: 0.0971 - acc: 0.9978     
Epoch 210/1000
1340/1340 [==============================] - 0s - loss: 0.1000 - acc: 0.9970     
Epoch 211/1000
1340/1340 [==============================] - 0s - loss: 0.1049 - acc: 0.9948     
Epoch 212/1000
1340/1340 [==============================] - 0s - loss: 0.0996 - acc: 0.9963     
Epoch 213/1000
1340/1340 [==============================] - 0s - loss: 0.1037 - acc: 0.9940     
Epoch 214/1000
1340/1340 [==============================] - 0s - loss: 0.1007 - acc: 0.9970     
Epoch 215/1000
1340/1340 [==============================] - 0s - loss: 0.0990 - acc: 0.9978     
Epoch 216/1000
1340/1340 [==============================] - 0s - loss: 0.0984 - acc: 0.9970     
Epoch 217/1000
1340/1340 [==============================] - 0s - loss: 0.0998 - acc: 0.9963     
Epoch 218/1000
1340/1340 [==============================] - 0s - loss: 0.0989 - acc: 0.9970     
Epoch 219/1000
1340/1340 [==============================] - 0s - loss: 0.0999 - acc: 0.9970     
Epoch 220/1000
1340/1340 [==============================] - 0s - loss: 0.1000 - acc: 0.9955     
Epoch 221/1000
1340/1340 [==============================] - 0s - loss: 0.0988 - acc: 0.9993     
Epoch 222/1000
1340/1340 [==============================] - 0s - loss: 0.0987 - acc: 0.9970     
Epoch 223/1000
1340/1340 [==============================] - 0s - loss: 0.0967 - acc: 0.9985     
Epoch 224/1000
1340/1340 [==============================] - 0s - loss: 0.0991 - acc: 0.9948     
Epoch 225/1000
1340/1340 [==============================] - 0s - loss: 0.0972 - acc: 0.9993     
Epoch 226/1000
1340/1340 [==============================] - 0s - loss: 0.0995 - acc: 0.9955     
Epoch 227/1000
1340/1340 [==============================] - 0s - loss: 0.0977 - acc: 0.9993     
Epoch 228/1000
1340/1340 [==============================] - 0s - loss: 0.0971 - acc: 0.9963     
Epoch 229/1000
1340/1340 [==============================] - 0s - loss: 0.0980 - acc: 0.9970     
Epoch 230/1000
1340/1340 [==============================] - 0s - loss: 0.0997 - acc: 0.9948     
Epoch 231/1000
1340/1340 [==============================] - 0s - loss: 0.0988 - acc: 0.9970     
Epoch 232/1000
1340/1340 [==============================] - 0s - loss: 0.0974 - acc: 0.9970     
Epoch 233/1000
1340/1340 [==============================] - 0s - loss: 0.0971 - acc: 0.9963     
Epoch 234/1000
1340/1340 [==============================] - 0s - loss: 0.0978 - acc: 0.9955     
Epoch 235/1000
1340/1340 [==============================] - 0s - loss: 0.0956 - acc: 0.9985     
Epoch 236/1000
1340/1340 [==============================] - 0s - loss: 0.1003 - acc: 0.9948     
Epoch 237/1000
1340/1340 [==============================] - 0s - loss: 0.0964 - acc: 0.9963     
Epoch 238/1000
1340/1340 [==============================] - 0s - loss: 0.0937 - acc: 0.9993     
Epoch 239/1000
1340/1340 [==============================] - 0s - loss: 0.0959 - acc: 0.9993     
Epoch 240/1000
1340/1340 [==============================] - 0s - loss: 0.0973 - acc: 0.9948     
Epoch 241/1000
1340/1340 [==============================] - 0s - loss: 0.0972 - acc: 0.9955     
Epoch 242/1000
1340/1340 [==============================] - 0s - loss: 0.0968 - acc: 0.9963     
Epoch 243/1000
1340/1340 [==============================] - 0s - loss: 0.0950 - acc: 0.9993     
Epoch 244/1000
1340/1340 [==============================] - 0s - loss: 0.0975 - acc: 0.9963     
Epoch 245/1000
1340/1340 [==============================] - 0s - loss: 0.0965 - acc: 0.9948     
Epoch 246/1000
1340/1340 [==============================] - 0s - loss: 0.0945 - acc: 0.9985     
Epoch 247/1000
1340/1340 [==============================] - 0s - loss: 0.0961 - acc: 0.9993     
Epoch 248/1000
1340/1340 [==============================] - 0s - loss: 0.0976 - acc: 0.9970     
Epoch 249/1000
1340/1340 [==============================] - 0s - loss: 0.0997 - acc: 0.9955     
Epoch 250/1000
1340/1340 [==============================] - 0s - loss: 0.0961 - acc: 0.9993     
Epoch 251/1000
1340/1340 [==============================] - 0s - loss: 0.0959 - acc: 1.0000     
Epoch 252/1000
1340/1340 [==============================] - 0s - loss: 0.0992 - acc: 0.9963     
Epoch 253/1000
1340/1340 [==============================] - 0s - loss: 0.0968 - acc: 0.9955     
Epoch 254/1000
1340/1340 [==============================] - 0s - loss: 0.0977 - acc: 0.9955     
Epoch 255/1000
1340/1340 [==============================] - 0s - loss: 0.0998 - acc: 0.9955     
Epoch 256/1000
1340/1340 [==============================] - 0s - loss: 0.0957 - acc: 0.9978     
Epoch 257/1000
1340/1340 [==============================] - 0s - loss: 0.0956 - acc: 0.9970     
Epoch 258/1000
1340/1340 [==============================] - 0s - loss: 0.0979 - acc: 0.9978     
Epoch 259/1000
1340/1340 [==============================] - 0s - loss: 0.0945 - acc: 0.9978     
Epoch 260/1000
1340/1340 [==============================] - 0s - loss: 0.0955 - acc: 0.9970     
Epoch 261/1000
1340/1340 [==============================] - 0s - loss: 0.1009 - acc: 0.9955     
Epoch 262/1000
1340/1340 [==============================] - 0s - loss: 0.0937 - acc: 1.0000     
Epoch 263/1000
1340/1340 [==============================] - 0s - loss: 0.0973 - acc: 0.9940     
Epoch 264/1000
1340/1340 [==============================] - 0s - loss: 0.0949 - acc: 0.9978     
Epoch 265/1000
1340/1340 [==============================] - 0s - loss: 0.0940 - acc: 0.9985     
Epoch 266/1000
1340/1340 [==============================] - 0s - loss: 0.0949 - acc: 0.9970     
Epoch 267/1000
1340/1340 [==============================] - 0s - loss: 0.0981 - acc: 0.9955     
Epoch 268/1000
1340/1340 [==============================] - 0s - loss: 0.0999 - acc: 0.9948     
Epoch 269/1000
1340/1340 [==============================] - 0s - loss: 0.0936 - acc: 0.9985     
Epoch 270/1000
1340/1340 [==============================] - 0s - loss: 0.0929 - acc: 0.9985     
Epoch 271/1000
1340/1340 [==============================] - 0s - loss: 0.0959 - acc: 0.9955     
Epoch 272/1000
1340/1340 [==============================] - 0s - loss: 0.0952 - acc: 0.9978     
Epoch 273/1000
1340/1340 [==============================] - 0s - loss: 0.0929 - acc: 0.9985     
Epoch 274/1000
1340/1340 [==============================] - 0s - loss: 0.0949 - acc: 0.9970     
Epoch 275/1000
1340/1340 [==============================] - 0s - loss: 0.0926 - acc: 0.9985     
Epoch 276/1000
1340/1340 [==============================] - 0s - loss: 0.0956 - acc: 0.9963     
Epoch 277/1000
1340/1340 [==============================] - 0s - loss: 0.0956 - acc: 0.9970     
Epoch 278/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9985     
Epoch 279/1000
1340/1340 [==============================] - 0s - loss: 0.0940 - acc: 0.9978     
Epoch 280/1000
1340/1340 [==============================] - 0s - loss: 0.0967 - acc: 0.9933     
Epoch 281/1000
1340/1340 [==============================] - 0s - loss: 0.0923 - acc: 0.9985     
Epoch 282/1000
1340/1340 [==============================] - 0s - loss: 0.0936 - acc: 0.9970     
Epoch 283/1000
1340/1340 [==============================] - 0s - loss: 0.0943 - acc: 0.9985     
Epoch 284/1000
1340/1340 [==============================] - 0s - loss: 0.0929 - acc: 0.9985     
Epoch 285/1000
1340/1340 [==============================] - 0s - loss: 0.0943 - acc: 0.9985     
Epoch 286/1000
1340/1340 [==============================] - 0s - loss: 0.0941 - acc: 0.9985     
Epoch 287/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9978     
Epoch 288/1000
1340/1340 [==============================] - 0s - loss: 0.0910 - acc: 0.9993     
Epoch 289/1000
1340/1340 [==============================] - 0s - loss: 0.0908 - acc: 1.0000     
Epoch 290/1000
1340/1340 [==============================] - 0s - loss: 0.0923 - acc: 0.9970     
Epoch 291/1000
1340/1340 [==============================] - 0s - loss: 0.0953 - acc: 0.9963     
Epoch 292/1000
1340/1340 [==============================] - 0s - loss: 0.0936 - acc: 0.9985     
Epoch 293/1000
1340/1340 [==============================] - 0s - loss: 0.0956 - acc: 0.9970     
Epoch 294/1000
1340/1340 [==============================] - 0s - loss: 0.0935 - acc: 0.9970     
Epoch 295/1000
1340/1340 [==============================] - 0s - loss: 0.0935 - acc: 0.9985     
Epoch 296/1000
1340/1340 [==============================] - 0s - loss: 0.0960 - acc: 0.9985     
Epoch 297/1000
1340/1340 [==============================] - 0s - loss: 0.0919 - acc: 0.9993     
Epoch 298/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9978     
Epoch 299/1000
1340/1340 [==============================] - 0s - loss: 0.0909 - acc: 0.9985     
Epoch 300/1000
1340/1340 [==============================] - 0s - loss: 0.0955 - acc: 0.9963     
Epoch 301/1000
1340/1340 [==============================] - 0s - loss: 0.0920 - acc: 0.9978     
Epoch 302/1000
1340/1340 [==============================] - 0s - loss: 0.0948 - acc: 0.9970     
Epoch 303/1000
1340/1340 [==============================] - 0s - loss: 0.0916 - acc: 0.9993     
Epoch 304/1000
1340/1340 [==============================] - 0s - loss: 0.0909 - acc: 0.9985     
Epoch 305/1000
1340/1340 [==============================] - 0s - loss: 0.0906 - acc: 0.9985     
Epoch 306/1000
1340/1340 [==============================] - 0s - loss: 0.0945 - acc: 0.9978     
Epoch 307/1000
1340/1340 [==============================] - 0s - loss: 0.0923 - acc: 0.9985     
Epoch 308/1000
1340/1340 [==============================] - 0s - loss: 0.0929 - acc: 0.9970     
Epoch 309/1000
1340/1340 [==============================] - 0s - loss: 0.0941 - acc: 0.9978     
Epoch 310/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9978     
Epoch 311/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9978     
Epoch 312/1000
1340/1340 [==============================] - 0s - loss: 0.0916 - acc: 0.9993     
Epoch 313/1000
1340/1340 [==============================] - 0s - loss: 0.0926 - acc: 0.9985     
Epoch 314/1000
1340/1340 [==============================] - 0s - loss: 0.0927 - acc: 1.0000     
Epoch 315/1000
1340/1340 [==============================] - 0s - loss: 0.0935 - acc: 0.9970     
Epoch 316/1000
1340/1340 [==============================] - 0s - loss: 0.0888 - acc: 1.0000     
Epoch 317/1000
1340/1340 [==============================] - 0s - loss: 0.0900 - acc: 0.9993     
Epoch 318/1000
1340/1340 [==============================] - 0s - loss: 0.0922 - acc: 0.9970     
Epoch 319/1000
1340/1340 [==============================] - 0s - loss: 0.0914 - acc: 0.9993     
Epoch 320/1000
1340/1340 [==============================] - 0s - loss: 0.0933 - acc: 0.9970     
Epoch 321/1000
1340/1340 [==============================] - 0s - loss: 0.0968 - acc: 0.9970     
Epoch 322/1000
1340/1340 [==============================] - 0s - loss: 0.0891 - acc: 0.9993     
Epoch 323/1000
1340/1340 [==============================] - 0s - loss: 0.0934 - acc: 0.9978     
Epoch 324/1000
1340/1340 [==============================] - 0s - loss: 0.0955 - acc: 0.9955     
Epoch 325/1000
1340/1340 [==============================] - 0s - loss: 0.0891 - acc: 1.0000     
Epoch 326/1000
1340/1340 [==============================] - 0s - loss: 0.0963 - acc: 0.9948     
Epoch 327/1000
1340/1340 [==============================] - 0s - loss: 0.0912 - acc: 0.9978     
Epoch 328/1000
1340/1340 [==============================] - 0s - loss: 0.0905 - acc: 0.9985     
Epoch 329/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9985     
Epoch 330/1000
1340/1340 [==============================] - 0s - loss: 0.0917 - acc: 0.9985     
Epoch 331/1000
1340/1340 [==============================] - 0s - loss: 0.0923 - acc: 0.9978     
Epoch 332/1000
1340/1340 [==============================] - 0s - loss: 0.0914 - acc: 0.9978     
Epoch 333/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9985     
Epoch 334/1000
1340/1340 [==============================] - 0s - loss: 0.0909 - acc: 0.9985     
Epoch 335/1000
1340/1340 [==============================] - 0s - loss: 0.0916 - acc: 0.9970     
Epoch 336/1000
1340/1340 [==============================] - 0s - loss: 0.0946 - acc: 0.9940     
Epoch 337/1000
1340/1340 [==============================] - 0s - loss: 0.0919 - acc: 0.9970     
Epoch 338/1000
1340/1340 [==============================] - 0s - loss: 0.0907 - acc: 0.9993     
Epoch 339/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9985     
Epoch 340/1000
1340/1340 [==============================] - 0s - loss: 0.0917 - acc: 0.9985     
Epoch 341/1000
1340/1340 [==============================] - 0s - loss: 0.0908 - acc: 0.9978     
Epoch 342/1000
1340/1340 [==============================] - 0s - loss: 0.0934 - acc: 0.9963     
Epoch 343/1000
1340/1340 [==============================] - 0s - loss: 0.0905 - acc: 0.9985     
Epoch 344/1000
1340/1340 [==============================] - 0s - loss: 0.0927 - acc: 0.9993     
Epoch 345/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9978     
Epoch 346/1000
1340/1340 [==============================] - 0s - loss: 0.0916 - acc: 0.9985     
Epoch 347/1000
1340/1340 [==============================] - 0s - loss: 0.0922 - acc: 0.9963     
Epoch 348/1000
1340/1340 [==============================] - 0s - loss: 0.0896 - acc: 0.9993     
Epoch 349/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9978     
Epoch 350/1000
1340/1340 [==============================] - 0s - loss: 0.0914 - acc: 0.9985     
Epoch 351/1000
1340/1340 [==============================] - 0s - loss: 0.0923 - acc: 0.9978     
Epoch 352/1000
1340/1340 [==============================] - 0s - loss: 0.0914 - acc: 0.9978     
Epoch 353/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9970     
Epoch 354/1000
1340/1340 [==============================] - 0s - loss: 0.0913 - acc: 0.9978     
Epoch 355/1000
1340/1340 [==============================] - 0s - loss: 0.0891 - acc: 1.0000     
Epoch 356/1000
1340/1340 [==============================] - 0s - loss: 0.0888 - acc: 0.9993     
Epoch 357/1000
1340/1340 [==============================] - 0s - loss: 0.0903 - acc: 0.9985     
Epoch 358/1000
1340/1340 [==============================] - 0s - loss: 0.0939 - acc: 0.9970     
Epoch 359/1000
1340/1340 [==============================] - 0s - loss: 0.0916 - acc: 0.9985     
Epoch 360/1000
1340/1340 [==============================] - 0s - loss: 0.0913 - acc: 0.9978     
Epoch 361/1000
1340/1340 [==============================] - 0s - loss: 0.0897 - acc: 0.9985     
Epoch 362/1000
1340/1340 [==============================] - 0s - loss: 0.0905 - acc: 1.0000     
Epoch 363/1000
1340/1340 [==============================] - 0s - loss: 0.0947 - acc: 0.9963     
Epoch 364/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9993     
Epoch 365/1000
1340/1340 [==============================] - 0s - loss: 0.0907 - acc: 0.9963     
Epoch 366/1000
1340/1340 [==============================] - 0s - loss: 0.0921 - acc: 0.9985     
Epoch 367/1000
1340/1340 [==============================] - 0s - loss: 0.0915 - acc: 0.9970     
Epoch 368/1000
1340/1340 [==============================] - 0s - loss: 0.0920 - acc: 0.9978     
Epoch 369/1000
1340/1340 [==============================] - 0s - loss: 0.0899 - acc: 0.9985     
Epoch 370/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9970     
Epoch 371/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9970     
Epoch 372/1000
1340/1340 [==============================] - 0s - loss: 0.0918 - acc: 0.9985     
Epoch 373/1000
1340/1340 [==============================] - 0s - loss: 0.0882 - acc: 0.9993     
Epoch 374/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 1.0000     
Epoch 375/1000
1340/1340 [==============================] - 0s - loss: 0.0906 - acc: 0.9993     
Epoch 376/1000
1340/1340 [==============================] - 0s - loss: 0.0894 - acc: 0.9985     
Epoch 377/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9985     
Epoch 378/1000
1340/1340 [==============================] - 0s - loss: 0.0938 - acc: 0.9970     
Epoch 379/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9970     
Epoch 380/1000
1340/1340 [==============================] - 0s - loss: 0.0897 - acc: 0.9985     
Epoch 381/1000
1340/1340 [==============================] - 0s - loss: 0.0894 - acc: 0.9993     
Epoch 382/1000
1340/1340 [==============================] - 0s - loss: 0.0909 - acc: 0.9978     
Epoch 383/1000
1340/1340 [==============================] - 0s - loss: 0.0913 - acc: 0.9978     
Epoch 384/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9993     
Epoch 385/1000
1340/1340 [==============================] - 0s - loss: 0.0903 - acc: 0.9985     
Epoch 386/1000
1340/1340 [==============================] - 0s - loss: 0.0928 - acc: 0.9963     
Epoch 387/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9985     
Epoch 388/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9993     
Epoch 389/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 0.9993     
Epoch 390/1000
1340/1340 [==============================] - 0s - loss: 0.0880 - acc: 1.0000     
Epoch 391/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9985     
Epoch 392/1000
1340/1340 [==============================] - 0s - loss: 0.0892 - acc: 0.9978     
Epoch 393/1000
1340/1340 [==============================] - 0s - loss: 0.0914 - acc: 0.9963     
Epoch 394/1000
1340/1340 [==============================] - 0s - loss: 0.0919 - acc: 0.9963     
Epoch 395/1000
1340/1340 [==============================] - 0s - loss: 0.0878 - acc: 0.9993     
Epoch 396/1000
1340/1340 [==============================] - 0s - loss: 0.0887 - acc: 0.9985     
Epoch 397/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9978     
Epoch 398/1000
1340/1340 [==============================] - 0s - loss: 0.0908 - acc: 0.9985     
Epoch 399/1000
1340/1340 [==============================] - 0s - loss: 0.0889 - acc: 1.0000     
Epoch 400/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9985     
Epoch 401/1000
1340/1340 [==============================] - 0s - loss: 0.0889 - acc: 0.9978     
Epoch 402/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9993     
Epoch 403/1000
1340/1340 [==============================] - 0s - loss: 0.0908 - acc: 0.9963     
Epoch 404/1000
1340/1340 [==============================] - 0s - loss: 0.0910 - acc: 0.9970     
Epoch 405/1000
1340/1340 [==============================] - 0s - loss: 0.0915 - acc: 0.9970     
Epoch 406/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9985     
Epoch 407/1000
1340/1340 [==============================] - 0s - loss: 0.0876 - acc: 0.9993     
Epoch 408/1000
1340/1340 [==============================] - 0s - loss: 0.0885 - acc: 0.9985     
Epoch 409/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9985     
Epoch 410/1000
1340/1340 [==============================] - 0s - loss: 0.0912 - acc: 0.9955     
Epoch 411/1000
1340/1340 [==============================] - 0s - loss: 0.0896 - acc: 0.9978     
Epoch 412/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9993     
Epoch 413/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9993     
Epoch 414/1000
1340/1340 [==============================] - 0s - loss: 0.0901 - acc: 0.9963     
Epoch 415/1000
1340/1340 [==============================] - 0s - loss: 0.0887 - acc: 0.9978     
Epoch 416/1000
1340/1340 [==============================] - 0s - loss: 0.0894 - acc: 0.9978     
Epoch 417/1000
1340/1340 [==============================] - 0s - loss: 0.0885 - acc: 0.9985     
Epoch 418/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9985     
Epoch 419/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9993     
Epoch 420/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9993     
Epoch 421/1000
1340/1340 [==============================] - 0s - loss: 0.0898 - acc: 0.9970     
Epoch 422/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9985     
Epoch 423/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9970     
Epoch 424/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9985     
Epoch 425/1000
1340/1340 [==============================] - 0s - loss: 0.0894 - acc: 0.9993     
Epoch 426/1000
1340/1340 [==============================] - 0s - loss: 0.0904 - acc: 0.9955     
Epoch 427/1000
1340/1340 [==============================] - 0s - loss: 0.0892 - acc: 0.9985     
Epoch 428/1000
1340/1340 [==============================] - 0s - loss: 0.0893 - acc: 0.9978     
Epoch 429/1000
1340/1340 [==============================] - 0s - loss: 0.0887 - acc: 0.9993     
Epoch 430/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9993     
Epoch 431/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9985     
Epoch 432/1000
1340/1340 [==============================] - 0s - loss: 0.0887 - acc: 0.9993     
Epoch 433/1000
1340/1340 [==============================] - 0s - loss: 0.0861 - acc: 1.0000     
Epoch 434/1000
1340/1340 [==============================] - 0s - loss: 0.0900 - acc: 0.9978     
Epoch 435/1000
1340/1340 [==============================] - 0s - loss: 0.0862 - acc: 1.0000     
Epoch 436/1000
1340/1340 [==============================] - 0s - loss: 0.0896 - acc: 0.9970     
Epoch 437/1000
1340/1340 [==============================] - 0s - loss: 0.0892 - acc: 0.9985     
Epoch 438/1000
1340/1340 [==============================] - 0s - loss: 0.0890 - acc: 0.9970     
Epoch 439/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9985     
Epoch 440/1000
1340/1340 [==============================] - 0s - loss: 0.0889 - acc: 0.9993     
Epoch 441/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9978     
Epoch 442/1000
1340/1340 [==============================] - 0s - loss: 0.0891 - acc: 0.9978     
Epoch 443/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9993     
Epoch 444/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9978     
Epoch 445/1000
1340/1340 [==============================] - 0s - loss: 0.0871 - acc: 0.9985     
Epoch 446/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9993     
Epoch 447/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9985     
Epoch 448/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 1.0000     
Epoch 449/1000
1340/1340 [==============================] - 0s - loss: 0.0943 - acc: 0.9955     
Epoch 450/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9970     
Epoch 451/1000
1340/1340 [==============================] - 0s - loss: 0.0878 - acc: 1.0000     
Epoch 452/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9985     
Epoch 453/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 0.9993     
Epoch 454/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9985     
Epoch 455/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9993     
Epoch 456/1000
1340/1340 [==============================] - 0s - loss: 0.0888 - acc: 0.9985     
Epoch 457/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9993     
Epoch 458/1000
1340/1340 [==============================] - 0s - loss: 0.0908 - acc: 0.9963     
Epoch 459/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9993     
Epoch 460/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9985     
Epoch 461/1000
1340/1340 [==============================] - 0s - loss: 0.0909 - acc: 0.9970     
Epoch 462/1000
1340/1340 [==============================] - 0s - loss: 0.0879 - acc: 0.9985     
Epoch 463/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9993     
Epoch 464/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 1.0000     
Epoch 465/1000
1340/1340 [==============================] - 0s - loss: 0.0871 - acc: 0.9985     
Epoch 466/1000
1340/1340 [==============================] - 0s - loss: 0.0862 - acc: 0.9993     
Epoch 467/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9985     
Epoch 468/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9985     
Epoch 469/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9985     
Epoch 470/1000
1340/1340 [==============================] - 0s - loss: 0.0881 - acc: 0.9985     
Epoch 471/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9993     
Epoch 472/1000
1340/1340 [==============================] - 0s - loss: 0.0860 - acc: 0.9993     
Epoch 473/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9985     
Epoch 474/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9993     
Epoch 475/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 1.0000     
Epoch 476/1000
1340/1340 [==============================] - 0s - loss: 0.0880 - acc: 0.9978     
Epoch 477/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9978     
Epoch 478/1000
1340/1340 [==============================] - 0s - loss: 0.0881 - acc: 0.9970     
Epoch 479/1000
1340/1340 [==============================] - 0s - loss: 0.0896 - acc: 0.9970     
Epoch 480/1000
1340/1340 [==============================] - 0s - loss: 0.0887 - acc: 0.9978     
Epoch 481/1000
1340/1340 [==============================] - 0s - loss: 0.0863 - acc: 0.9993     
Epoch 482/1000
1340/1340 [==============================] - 0s - loss: 0.0864 - acc: 0.9993     
Epoch 483/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 0.9993     
Epoch 484/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9985     
Epoch 485/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 1.0000     
Epoch 486/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9985     
Epoch 487/1000
1340/1340 [==============================] - 0s - loss: 0.0911 - acc: 0.9963     
Epoch 488/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 0.9993     
Epoch 489/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9985     
Epoch 490/1000
1340/1340 [==============================] - 0s - loss: 0.0889 - acc: 0.9978     
Epoch 491/1000
1340/1340 [==============================] - 0s - loss: 0.0888 - acc: 0.9970     
Epoch 492/1000
1340/1340 [==============================] - 0s - loss: 0.0871 - acc: 0.9993     
Epoch 493/1000
1340/1340 [==============================] - 0s - loss: 0.0886 - acc: 0.9963     
Epoch 494/1000
1340/1340 [==============================] - 0s - loss: 0.0863 - acc: 1.0000     
Epoch 495/1000
1340/1340 [==============================] - 0s - loss: 0.0863 - acc: 0.9993     
Epoch 496/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9993     
Epoch 497/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9985     
Epoch 498/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9985     
Epoch 499/1000
1340/1340 [==============================] - 0s - loss: 0.0881 - acc: 0.9978     
Epoch 500/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9978     
Epoch 501/1000
1340/1340 [==============================] - 0s - loss: 0.0879 - acc: 0.9985     
Epoch 502/1000
1340/1340 [==============================] - 0s - loss: 0.0842 - acc: 1.0000     
Epoch 503/1000
1340/1340 [==============================] - 0s - loss: 0.0871 - acc: 0.9978     
Epoch 504/1000
1340/1340 [==============================] - 0s - loss: 0.0851 - acc: 1.0000     
Epoch 505/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9993     
Epoch 506/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9970     
Epoch 507/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9993     
Epoch 508/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9993     
Epoch 509/1000
1340/1340 [==============================] - 0s - loss: 0.0878 - acc: 0.9978     
Epoch 510/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9985     
Epoch 511/1000
1340/1340 [==============================] - 0s - loss: 0.0854 - acc: 1.0000     
Epoch 512/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9985     
Epoch 513/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9993     
Epoch 514/1000
1340/1340 [==============================] - 0s - loss: 0.0895 - acc: 0.9963     
Epoch 515/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 1.0000     
Epoch 516/1000
1340/1340 [==============================] - 0s - loss: 0.0850 - acc: 0.9993     
Epoch 517/1000
1340/1340 [==============================] - 0s - loss: 0.0854 - acc: 0.9993     
Epoch 518/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 0.9970     
Epoch 519/1000
1340/1340 [==============================] - 0s - loss: 0.0864 - acc: 0.9993     
Epoch 520/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9985     
Epoch 521/1000
1340/1340 [==============================] - 0s - loss: 0.0864 - acc: 0.9985     
Epoch 522/1000
1340/1340 [==============================] - 0s - loss: 0.0855 - acc: 0.9993     
Epoch 523/1000
1340/1340 [==============================] - 0s - loss: 0.0861 - acc: 0.9993     
Epoch 524/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 0.9985     
Epoch 525/1000
1340/1340 [==============================] - 0s - loss: 0.0871 - acc: 0.9985     
Epoch 526/1000
1340/1340 [==============================] - 0s - loss: 0.0843 - acc: 1.0000     
Epoch 527/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9985     
Epoch 528/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9985     
Epoch 529/1000
1340/1340 [==============================] - 0s - loss: 0.0879 - acc: 0.9985     
Epoch 530/1000
1340/1340 [==============================] - 0s - loss: 0.0878 - acc: 0.9978     
Epoch 531/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9963     
Epoch 532/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9993     
Epoch 533/1000
1340/1340 [==============================] - 0s - loss: 0.0849 - acc: 1.0000     
Epoch 534/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9993     
Epoch 535/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9963     
Epoch 536/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9993     
Epoch 537/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9978     
Epoch 538/1000
1340/1340 [==============================] - 0s - loss: 0.0884 - acc: 0.9963     
Epoch 539/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9985     
Epoch 540/1000
1340/1340 [==============================] - 0s - loss: 0.0865 - acc: 0.9978     
Epoch 541/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9985     
Epoch 542/1000
1340/1340 [==============================] - 0s - loss: 0.0860 - acc: 0.9985     
Epoch 543/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9978     
Epoch 544/1000
1340/1340 [==============================] - 0s - loss: 0.0865 - acc: 0.9985     
Epoch 545/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9993     
Epoch 546/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9993     
Epoch 547/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9985     
Epoch 548/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9978     
Epoch 549/1000
1340/1340 [==============================] - 0s - loss: 0.0874 - acc: 0.9978     
Epoch 550/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9985     
Epoch 551/1000
1340/1340 [==============================] - 0s - loss: 0.0864 - acc: 0.9993     
Epoch 552/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 0.9993     
Epoch 553/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9978     
Epoch 554/1000
1340/1340 [==============================] - 0s - loss: 0.0865 - acc: 0.9985     
Epoch 555/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9985     
Epoch 556/1000
1340/1340 [==============================] - 0s - loss: 0.0867 - acc: 0.9993     
Epoch 557/1000
1340/1340 [==============================] - 0s - loss: 0.0865 - acc: 0.9985     
Epoch 558/1000
1340/1340 [==============================] - 0s - loss: 0.0900 - acc: 0.9948     
Epoch 559/1000
1340/1340 [==============================] - 0s - loss: 0.0869 - acc: 0.9985     
Epoch 560/1000
1340/1340 [==============================] - 0s - loss: 0.0864 - acc: 0.9993     
Epoch 561/1000
1340/1340 [==============================] - 0s - loss: 0.0855 - acc: 1.0000     
Epoch 562/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 1.0000     
Epoch 563/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9985     
Epoch 564/1000
1340/1340 [==============================] - 0s - loss: 0.0876 - acc: 0.9978     
Epoch 565/1000
1340/1340 [==============================] - 0s - loss: 0.0877 - acc: 0.9963     
Epoch 566/1000
1340/1340 [==============================] - 0s - loss: 0.0883 - acc: 0.9978     
Epoch 567/1000
1340/1340 [==============================] - 0s - loss: 0.0845 - acc: 0.9993     
Epoch 568/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 1.0000     
Epoch 569/1000
1340/1340 [==============================] - 0s - loss: 0.0880 - acc: 0.9970     
Epoch 570/1000
1340/1340 [==============================] - 0s - loss: 0.0863 - acc: 0.9993     
Epoch 571/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 1.0000     
Epoch 572/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9993     
Epoch 573/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9970     
Epoch 574/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 1.0000     
Epoch 575/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 1.0000     
Epoch 576/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9993     
Epoch 577/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9985     
Epoch 578/1000
1340/1340 [==============================] - 0s - loss: 0.0851 - acc: 0.9993     
Epoch 579/1000
1340/1340 [==============================] - 0s - loss: 0.0863 - acc: 0.9970     
Epoch 580/1000
1340/1340 [==============================] - 0s - loss: 0.0862 - acc: 0.9985     
Epoch 581/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9985     
Epoch 582/1000
1340/1340 [==============================] - 0s - loss: 0.0866 - acc: 0.9978     
Epoch 583/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9993     
Epoch 584/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9985     
Epoch 585/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 1.0000     
Epoch 586/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 1.0000     
Epoch 587/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9985     
Epoch 588/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 1.0000     
Epoch 589/1000
1340/1340 [==============================] - 0s - loss: 0.0855 - acc: 0.9985     
Epoch 590/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9993     
Epoch 591/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 1.0000     
Epoch 592/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9993     
Epoch 593/1000
1340/1340 [==============================] - 0s - loss: 0.0850 - acc: 0.9978     
Epoch 594/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9993     
Epoch 595/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 1.0000     
Epoch 596/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9985     
Epoch 597/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 598/1000
1340/1340 [==============================] - 0s - loss: 0.0875 - acc: 0.9978     
Epoch 599/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 1.0000     
Epoch 600/1000
1340/1340 [==============================] - 0s - loss: 0.0870 - acc: 0.9970     
Epoch 601/1000
1340/1340 [==============================] - 0s - loss: 0.0846 - acc: 0.9993     
Epoch 602/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9978     
Epoch 603/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 1.0000     
Epoch 604/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9985     
Epoch 605/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9993     
Epoch 606/1000
1340/1340 [==============================] - 0s - loss: 0.0857 - acc: 0.9985     
Epoch 607/1000
1340/1340 [==============================] - 0s - loss: 0.0854 - acc: 0.9985     
Epoch 608/1000
1340/1340 [==============================] - 0s - loss: 0.0860 - acc: 0.9985     
Epoch 609/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9993     
Epoch 610/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9985     
Epoch 611/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9985     
Epoch 612/1000
1340/1340 [==============================] - 0s - loss: 0.0845 - acc: 0.9985     
Epoch 613/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9985     
Epoch 614/1000
1340/1340 [==============================] - 0s - loss: 0.0872 - acc: 0.9970     
Epoch 615/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9993     
Epoch 616/1000
1340/1340 [==============================] - 0s - loss: 0.0873 - acc: 0.9970     
Epoch 617/1000
1340/1340 [==============================] - 0s - loss: 0.0842 - acc: 0.9993     
Epoch 618/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9985     
Epoch 619/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9993     
Epoch 620/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 0.9985     
Epoch 621/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9993     
Epoch 622/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 1.0000     
Epoch 623/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9985     
Epoch 624/1000
1340/1340 [==============================] - 0s - loss: 0.0854 - acc: 0.9985     
Epoch 625/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9978     
Epoch 626/1000
1340/1340 [==============================] - 0s - loss: 0.0849 - acc: 0.9985     
Epoch 627/1000
1340/1340 [==============================] - 0s - loss: 0.0893 - acc: 0.9963     
Epoch 628/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 1.0000     
Epoch 629/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 0.9993     
Epoch 630/1000
1340/1340 [==============================] - 0s - loss: 0.0855 - acc: 0.9978     
Epoch 631/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9970     
Epoch 632/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 633/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9993     
Epoch 634/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 1.0000     
Epoch 635/1000
1340/1340 [==============================] - 0s - loss: 0.0857 - acc: 0.9985     
Epoch 636/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 1.0000     
Epoch 637/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9993     
Epoch 638/1000
1340/1340 [==============================] - 0s - loss: 0.0824 - acc: 0.9993     
Epoch 639/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 0.9978     
Epoch 640/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 0.9993     
Epoch 641/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 0.9993     
Epoch 642/1000
1340/1340 [==============================] - 0s - loss: 0.0842 - acc: 0.9985     
Epoch 643/1000
1340/1340 [==============================] - 0s - loss: 0.0849 - acc: 0.9985     
Epoch 644/1000
1340/1340 [==============================] - 0s - loss: 0.0853 - acc: 0.9970     
Epoch 645/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9985     
Epoch 646/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9985     
Epoch 647/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9993     
Epoch 648/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 649/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 1.0000     
Epoch 650/1000
1340/1340 [==============================] - 0s - loss: 0.0846 - acc: 0.9985     
Epoch 651/1000
1340/1340 [==============================] - 0s - loss: 0.0868 - acc: 0.9978     
Epoch 652/1000
1340/1340 [==============================] - 0s - loss: 0.0886 - acc: 0.9955     
Epoch 653/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 654/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 1.0000     
Epoch 655/1000
1340/1340 [==============================] - 0s - loss: 0.0826 - acc: 1.0000     
Epoch 656/1000
1340/1340 [==============================] - 0s - loss: 0.0819 - acc: 1.0000     
Epoch 657/1000
1340/1340 [==============================] - 0s - loss: 0.0858 - acc: 0.9978     
Epoch 658/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9985     
Epoch 659/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9985     
Epoch 660/1000
1340/1340 [==============================] - 0s - loss: 0.0839 - acc: 0.9985     
Epoch 661/1000
1340/1340 [==============================] - 0s - loss: 0.0839 - acc: 0.9985     
Epoch 662/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 663/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9993     
Epoch 664/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9985     
Epoch 665/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9970     
Epoch 666/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9985     
Epoch 667/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 1.0000     
Epoch 668/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9993     
Epoch 669/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9993     
Epoch 670/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9993     
Epoch 671/1000
1340/1340 [==============================] - 0s - loss: 0.0855 - acc: 0.9978     
Epoch 672/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9985     
Epoch 673/1000
1340/1340 [==============================] - 0s - loss: 0.0821 - acc: 1.0000     
Epoch 674/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 675/1000
1340/1340 [==============================] - 0s - loss: 0.0848 - acc: 0.9993     
Epoch 676/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9993     
Epoch 677/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9978     
Epoch 678/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9993     
Epoch 679/1000
1340/1340 [==============================] - 0s - loss: 0.0851 - acc: 0.9970     
Epoch 680/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9985     
Epoch 681/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9978     
Epoch 682/1000
1340/1340 [==============================] - 0s - loss: 0.0854 - acc: 0.9993     - ETA: 0s - loss: 0.0843 - acc
Epoch 683/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9985     
Epoch 684/1000
1340/1340 [==============================] - 0s - loss: 0.0846 - acc: 0.9985     
Epoch 685/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 1.0000     
Epoch 686/1000
1340/1340 [==============================] - 0s - loss: 0.0844 - acc: 0.9985     
Epoch 687/1000
1340/1340 [==============================] - 0s - loss: 0.0851 - acc: 0.9978     
Epoch 688/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9993     
Epoch 689/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9993     
Epoch 690/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 1.0000     
Epoch 691/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 1.0000     
Epoch 692/1000
1340/1340 [==============================] - 0s - loss: 0.0846 - acc: 0.9985     
Epoch 693/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9978     
Epoch 694/1000
1340/1340 [==============================] - 0s - loss: 0.0842 - acc: 0.9985     
Epoch 695/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 0.9985     
Epoch 696/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9985     
Epoch 697/1000
1340/1340 [==============================] - 0s - loss: 0.0852 - acc: 0.9978     
Epoch 698/1000
1340/1340 [==============================] - 0s - loss: 0.0861 - acc: 0.9978     
Epoch 699/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9978     
Epoch 700/1000
1340/1340 [==============================] - 0s - loss: 0.0826 - acc: 0.9993     
Epoch 701/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 702/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 0.9985     
Epoch 703/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9985     
Epoch 704/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 1.0000     
Epoch 705/1000
1340/1340 [==============================] - 0s - loss: 0.0843 - acc: 0.9985     
Epoch 706/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 0.9993     
Epoch 707/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 1.0000     
Epoch 708/1000
1340/1340 [==============================] - 0s - loss: 0.0815 - acc: 0.9993     
Epoch 709/1000
1340/1340 [==============================] - 0s - loss: 0.0846 - acc: 0.9978     
Epoch 710/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 1.0000     
Epoch 711/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9985     
Epoch 712/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9978     
Epoch 713/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 1.0000     
Epoch 714/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 715/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9978     
Epoch 716/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9985     
Epoch 717/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9985     
Epoch 718/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 1.0000     
Epoch 719/1000
1340/1340 [==============================] - 0s - loss: 0.0814 - acc: 1.0000     
Epoch 720/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9978     
Epoch 721/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9993     
Epoch 722/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9985     
Epoch 723/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 0.9985     
Epoch 724/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 725/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 0.9993     
Epoch 726/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9993     
Epoch 727/1000
1340/1340 [==============================] - 0s - loss: 0.0856 - acc: 0.9978     
Epoch 728/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9985     
Epoch 729/1000
1340/1340 [==============================] - 0s - loss: 0.0848 - acc: 0.9978     
Epoch 730/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9993     
Epoch 731/1000
1340/1340 [==============================] - 0s - loss: 0.0824 - acc: 0.9993     
Epoch 732/1000
1340/1340 [==============================] - 0s - loss: 0.0817 - acc: 1.0000     
Epoch 733/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 1.0000     
Epoch 734/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9985     
Epoch 735/1000
1340/1340 [==============================] - 0s - loss: 0.0826 - acc: 0.9985     
Epoch 736/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9993     
Epoch 737/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9985     
Epoch 738/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 0.9985     
Epoch 739/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9970     
Epoch 740/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 1.0000     
Epoch 741/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 1.0000     
Epoch 742/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 0.9985     
Epoch 743/1000
1340/1340 [==============================] - 0s - loss: 0.0814 - acc: 1.0000     
Epoch 744/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9985     
Epoch 745/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9993     
Epoch 746/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 1.0000     
Epoch 747/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9985     
Epoch 748/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 1.0000     
Epoch 749/1000
1340/1340 [==============================] - 0s - loss: 0.0806 - acc: 0.9993     
Epoch 750/1000
1340/1340 [==============================] - 0s - loss: 0.0840 - acc: 0.9985     
Epoch 751/1000
1340/1340 [==============================] - 0s - loss: 0.0826 - acc: 0.9993     
Epoch 752/1000
1340/1340 [==============================] - 0s - loss: 0.0821 - acc: 0.9985     
Epoch 753/1000
1340/1340 [==============================] - 0s - loss: 0.0809 - acc: 0.9993     
Epoch 754/1000
1340/1340 [==============================] - 0s - loss: 0.0816 - acc: 1.0000     
Epoch 755/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9978     
Epoch 756/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 1.0000     
Epoch 757/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9978     
Epoch 758/1000
1340/1340 [==============================] - 0s - loss: 0.0859 - acc: 0.9955     
Epoch 759/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9978     
Epoch 760/1000
1340/1340 [==============================] - 0s - loss: 0.0839 - acc: 0.9978     
Epoch 761/1000
1340/1340 [==============================] - 0s - loss: 0.0817 - acc: 0.9993     
Epoch 762/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9993     
Epoch 763/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 1.0000     
Epoch 764/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 0.9993     
Epoch 765/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9985     
Epoch 766/1000
1340/1340 [==============================] - 0s - loss: 0.0838 - acc: 0.9978     
Epoch 767/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9985     
Epoch 768/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 0.9978     
Epoch 769/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 770/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 1.0000     
Epoch 771/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 0.9993     
Epoch 772/1000
1340/1340 [==============================] - 0s - loss: 0.0816 - acc: 0.9993     
Epoch 773/1000
1340/1340 [==============================] - 0s - loss: 0.0832 - acc: 0.9985     
Epoch 774/1000
1340/1340 [==============================] - 0s - loss: 0.0820 - acc: 0.9985     
Epoch 775/1000
1340/1340 [==============================] - 0s - loss: 0.0835 - acc: 0.9978     
Epoch 776/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 1.0000     
Epoch 777/1000
1340/1340 [==============================] - 0s - loss: 0.0805 - acc: 1.0000     
Epoch 778/1000
1340/1340 [==============================] - 0s - loss: 0.0843 - acc: 0.9970     
Epoch 779/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9993     
Epoch 780/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9978     
Epoch 781/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9985     
Epoch 782/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9985     
Epoch 783/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9993     
Epoch 784/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9978     
Epoch 785/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9978     
Epoch 786/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9993     
Epoch 787/1000
1340/1340 [==============================] - 0s - loss: 0.0795 - acc: 1.0000     
Epoch 788/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 0.9985     
Epoch 789/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9970     
Epoch 790/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 0.9985     
Epoch 791/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 1.0000     
Epoch 792/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 0.9993     
Epoch 793/1000
1340/1340 [==============================] - 0s - loss: 0.0811 - acc: 0.9985     
Epoch 794/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 795/1000
1340/1340 [==============================] - 0s - loss: 0.0839 - acc: 0.9978     
Epoch 796/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 0.9985     
Epoch 797/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 0.9993     
Epoch 798/1000
1340/1340 [==============================] - 0s - loss: 0.0795 - acc: 1.0000     
Epoch 799/1000
1340/1340 [==============================] - 0s - loss: 0.0819 - acc: 0.9985     
Epoch 800/1000
1340/1340 [==============================] - 0s - loss: 0.0832 - acc: 0.9978     
Epoch 801/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9970     
Epoch 802/1000
1340/1340 [==============================] - 0s - loss: 0.0834 - acc: 0.9970     
Epoch 803/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 0.9970     
Epoch 804/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 1.0000     
Epoch 805/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9993     
Epoch 806/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 0.9993     
Epoch 807/1000
1340/1340 [==============================] - 0s - loss: 0.0824 - acc: 0.9978     
Epoch 808/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9963     
Epoch 809/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 1.0000     
Epoch 810/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 811/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 1.0000     
Epoch 812/1000
1340/1340 [==============================] - 0s - loss: 0.0821 - acc: 0.9993     
Epoch 813/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 0.9985     
Epoch 814/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9993     
Epoch 815/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9985     
Epoch 816/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9985     
Epoch 817/1000
1340/1340 [==============================] - 0s - loss: 0.0809 - acc: 0.9993     
Epoch 818/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 0.9993     
Epoch 819/1000
1340/1340 [==============================] - 0s - loss: 0.0816 - acc: 0.9993     
Epoch 820/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 1.0000     
Epoch 821/1000
1340/1340 [==============================] - 0s - loss: 0.0806 - acc: 0.9985     
Epoch 822/1000
1340/1340 [==============================] - 0s - loss: 0.0798 - acc: 1.0000     
Epoch 823/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9978     
Epoch 824/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 825/1000
1340/1340 [==============================] - 0s - loss: 0.0831 - acc: 0.9970     
Epoch 826/1000
1340/1340 [==============================] - 0s - loss: 0.0798 - acc: 0.9993     
Epoch 827/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 1.0000     
Epoch 828/1000
1340/1340 [==============================] - 0s - loss: 0.0847 - acc: 0.9948     
Epoch 829/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 0.9993     
Epoch 830/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 0.9985     
Epoch 831/1000
1340/1340 [==============================] - 0s - loss: 0.0830 - acc: 0.9978     
Epoch 832/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9993     
Epoch 833/1000
1340/1340 [==============================] - 0s - loss: 0.0805 - acc: 1.0000     
Epoch 834/1000
1340/1340 [==============================] - 0s - loss: 0.0809 - acc: 0.9993     
Epoch 835/1000
1340/1340 [==============================] - 0s - loss: 0.0796 - acc: 1.0000     
Epoch 836/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 1.0000     
Epoch 837/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9978     
Epoch 838/1000
1340/1340 [==============================] - 0s - loss: 0.0837 - acc: 0.9963     
Epoch 839/1000
1340/1340 [==============================] - 0s - loss: 0.0798 - acc: 0.9993     
Epoch 840/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9993     
Epoch 841/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 0.9985     
Epoch 842/1000
1340/1340 [==============================] - 0s - loss: 0.0817 - acc: 0.9993     
Epoch 843/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9985     
Epoch 844/1000
1340/1340 [==============================] - ETA: 0s - loss: 0.0825 - acc: 0.997 - 0s - loss: 0.0826 - acc: 0.9978     
Epoch 845/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 846/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9993     
Epoch 847/1000
1340/1340 [==============================] - 0s - loss: 0.0819 - acc: 0.9978     
Epoch 848/1000
1340/1340 [==============================] - 0s - loss: 0.0806 - acc: 0.9993     
Epoch 849/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 0.9993     
Epoch 850/1000
1340/1340 [==============================] - 0s - loss: 0.0814 - acc: 0.9985     
Epoch 851/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 852/1000
1340/1340 [==============================] - 0s - loss: 0.0805 - acc: 0.9985     
Epoch 853/1000
1340/1340 [==============================] - 0s - loss: 0.0814 - acc: 0.9985     
Epoch 854/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9993     
Epoch 855/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9985     
Epoch 856/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9978     
Epoch 857/1000
1340/1340 [==============================] - 0s - loss: 0.0826 - acc: 0.9978     
Epoch 858/1000
1340/1340 [==============================] - 0s - loss: 0.0811 - acc: 0.9993     
Epoch 859/1000
1340/1340 [==============================] - 0s - loss: 0.0805 - acc: 1.0000     
Epoch 860/1000
1340/1340 [==============================] - 0s - loss: 0.0836 - acc: 0.9970     
Epoch 861/1000
1340/1340 [==============================] - 0s - loss: 0.0841 - acc: 0.9978     
Epoch 862/1000
1340/1340 [==============================] - 0s - loss: 0.0809 - acc: 0.9985     
Epoch 863/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 1.0000     
Epoch 864/1000
1340/1340 [==============================] - 0s - loss: 0.0797 - acc: 1.0000     
Epoch 865/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 0.9993     
Epoch 866/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9993     
Epoch 867/1000
1340/1340 [==============================] - 0s - loss: 0.0828 - acc: 0.9970     
Epoch 868/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 1.0000     
Epoch 869/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 0.9993     
Epoch 870/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 0.9985     
Epoch 871/1000
1340/1340 [==============================] - 0s - loss: 0.0816 - acc: 0.9978     
Epoch 872/1000
1340/1340 [==============================] - 0s - loss: 0.0788 - acc: 1.0000     
Epoch 873/1000
1340/1340 [==============================] - 0s - loss: 0.4104 - acc: 0.9687     
Epoch 874/1000
1340/1340 [==============================] - 0s - loss: 0.0817 - acc: 0.9985     
Epoch 875/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9993     
Epoch 876/1000
1340/1340 [==============================] - 0s - loss: 0.0817 - acc: 0.9978     
Epoch 877/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 0.9993     
Epoch 878/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 0.9978     
Epoch 879/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9985     
Epoch 880/1000
1340/1340 [==============================] - 0s - loss: 0.0785 - acc: 1.0000     
Epoch 881/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9993     
Epoch 882/1000
1340/1340 [==============================] - 0s - loss: 0.0796 - acc: 0.9993     
Epoch 883/1000
1340/1340 [==============================] - 0s - loss: 0.0790 - acc: 1.0000     
Epoch 884/1000
1340/1340 [==============================] - 0s - loss: 0.0812 - acc: 0.9978     
Epoch 885/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 886/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 887/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9985     
Epoch 888/1000
1340/1340 [==============================] - 0s - loss: 0.0792 - acc: 0.9993     
Epoch 889/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 1.0000     
Epoch 890/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9993     
Epoch 891/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 892/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 893/1000
1340/1340 [==============================] - 0s - loss: 0.0794 - acc: 0.9993     
Epoch 894/1000
1340/1340 [==============================] - 0s - loss: 0.0797 - acc: 0.9993     
Epoch 895/1000
1340/1340 [==============================] - 0s - loss: 0.0833 - acc: 0.9970     
Epoch 896/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 1.0000     
Epoch 897/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 1.0000     
Epoch 898/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9978     
Epoch 899/1000
1340/1340 [==============================] - 0s - loss: 0.0827 - acc: 0.9970     
Epoch 900/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 0.9985     
Epoch 901/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 902/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 903/1000
1340/1340 [==============================] - 0s - loss: 0.0787 - acc: 1.0000     
Epoch 904/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9970     
Epoch 905/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 906/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9985     
Epoch 907/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 1.0000     
Epoch 908/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 909/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 0.9993     
Epoch 910/1000
1340/1340 [==============================] - 0s - loss: 0.0822 - acc: 0.9970     
Epoch 911/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9978     
Epoch 912/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9993     
Epoch 913/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9985     
Epoch 914/1000
1340/1340 [==============================] - 0s - loss: 0.0806 - acc: 0.9985     
Epoch 915/1000
1340/1340 [==============================] - 0s - loss: 0.0787 - acc: 1.0000     
Epoch 916/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9993     
Epoch 917/1000
1340/1340 [==============================] - 0s - loss: 0.0797 - acc: 0.9993     
Epoch 918/1000
1340/1340 [==============================] - 0s - loss: 0.0796 - acc: 0.9993     
Epoch 919/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 0.9985     
Epoch 920/1000
1340/1340 [==============================] - 0s - loss: 0.0795 - acc: 0.9993     
Epoch 921/1000
1340/1340 [==============================] - 0s - loss: 0.0789 - acc: 1.0000     
Epoch 922/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9993     
Epoch 923/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 924/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9993     
Epoch 925/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 926/1000
1340/1340 [==============================] - 0s - loss: 0.0784 - acc: 0.9993     
Epoch 927/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 0.9985     
Epoch 928/1000
1340/1340 [==============================] - 0s - loss: 0.0802 - acc: 0.9993     
Epoch 929/1000
1340/1340 [==============================] - 0s - loss: 0.0795 - acc: 0.9985     
Epoch 930/1000
1340/1340 [==============================] - 0s - loss: 0.0794 - acc: 0.9993     
Epoch 931/1000
1340/1340 [==============================] - 0s - loss: 0.0780 - acc: 1.0000     
Epoch 932/1000
1340/1340 [==============================] - 0s - loss: 0.0811 - acc: 0.9970     
Epoch 933/1000
1340/1340 [==============================] - 0s - loss: 0.0818 - acc: 0.9978     
Epoch 934/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 1.0000     
Epoch 935/1000
1340/1340 [==============================] - 0s - loss: 0.0772 - acc: 1.0000     
Epoch 936/1000
1340/1340 [==============================] - 0s - loss: 0.0784 - acc: 1.0000     
Epoch 937/1000
1340/1340 [==============================] - 0s - loss: 0.0815 - acc: 0.9985     
Epoch 938/1000
1340/1340 [==============================] - 0s - loss: 0.0823 - acc: 0.9963     
Epoch 939/1000
1340/1340 [==============================] - 0s - loss: 0.0781 - acc: 1.0000     
Epoch 940/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9993     
Epoch 941/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9985     
Epoch 942/1000
1340/1340 [==============================] - 0s - loss: 0.0787 - acc: 0.9993     
Epoch 943/1000
1340/1340 [==============================] - 0s - loss: 0.0780 - acc: 1.0000     
Epoch 944/1000
1340/1340 [==============================] - 0s - loss: 0.0813 - acc: 0.9985     
Epoch 945/1000
1340/1340 [==============================] - 0s - loss: 0.0789 - acc: 0.9993     
Epoch 946/1000
1340/1340 [==============================] - 0s - loss: 0.0795 - acc: 0.9985     
Epoch 947/1000
1340/1340 [==============================] - 0s - loss: 0.0781 - acc: 1.0000     
Epoch 948/1000
1340/1340 [==============================] - 0s - loss: 0.0783 - acc: 1.0000     
Epoch 949/1000
1340/1340 [==============================] - 0s - loss: 0.0800 - acc: 0.9985     
Epoch 950/1000
1340/1340 [==============================] - 0s - loss: 0.0789 - acc: 0.9993     
Epoch 951/1000
1340/1340 [==============================] - 0s - loss: 0.0779 - acc: 1.0000     
Epoch 952/1000
1340/1340 [==============================] - 0s - loss: 0.0788 - acc: 1.0000     
Epoch 953/1000
1340/1340 [==============================] - 0s - loss: 0.0792 - acc: 1.0000     
Epoch 954/1000
1340/1340 [==============================] - 0s - loss: 0.0789 - acc: 0.9985     
Epoch 955/1000
1340/1340 [==============================] - 0s - loss: 0.0790 - acc: 0.9993     
Epoch 956/1000
1340/1340 [==============================] - 0s - loss: 0.0794 - acc: 0.9985     
Epoch 957/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 0.9993     
Epoch 958/1000
1340/1340 [==============================] - 0s - loss: 0.0791 - acc: 0.9993     
Epoch 959/1000
1340/1340 [==============================] - 0s - loss: 0.0790 - acc: 0.9993     
Epoch 960/1000
1340/1340 [==============================] - 0s - loss: 0.0805 - acc: 0.9970     
Epoch 961/1000
1340/1340 [==============================] - 0s - loss: 0.0798 - acc: 0.9985     
Epoch 962/1000
1340/1340 [==============================] - 0s - loss: 0.0771 - acc: 1.0000     
Epoch 963/1000
1340/1340 [==============================] - 0s - loss: 0.0783 - acc: 0.9993     
Epoch 964/1000
1340/1340 [==============================] - 0s - loss: 0.0779 - acc: 1.0000     
Epoch 965/1000
1340/1340 [==============================] - 0s - loss: 0.0829 - acc: 0.9955     
Epoch 966/1000
1340/1340 [==============================] - 0s - loss: 0.0798 - acc: 0.9985     
Epoch 967/1000
1340/1340 [==============================] - 0s - loss: 0.0787 - acc: 1.0000     
Epoch 968/1000
1340/1340 [==============================] - 0s - loss: 0.0787 - acc: 0.9993     
Epoch 969/1000
1340/1340 [==============================] - 0s - loss: 0.0825 - acc: 0.9963     
Epoch 970/1000
1340/1340 [==============================] - 0s - loss: 0.0781 - acc: 1.0000     
Epoch 971/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 0.9993     
Epoch 972/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9978     
Epoch 973/1000
1340/1340 [==============================] - 0s - loss: 0.0793 - acc: 0.9993     
Epoch 974/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9985     
Epoch 975/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9978     
Epoch 976/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 0.9978     
Epoch 977/1000
1340/1340 [==============================] - 0s - loss: 0.0804 - acc: 0.9978     
Epoch 978/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 0.9970     
Epoch 979/1000
1340/1340 [==============================] - 0s - loss: 0.0790 - acc: 0.9985     
Epoch 980/1000
1340/1340 [==============================] - 0s - loss: 0.0780 - acc: 0.9993     
Epoch 981/1000
1340/1340 [==============================] - 0s - loss: 0.0809 - acc: 0.9970     
Epoch 982/1000
1340/1340 [==============================] - 0s - loss: 0.0808 - acc: 0.9970     
Epoch 983/1000
1340/1340 [==============================] - 0s - loss: 0.0807 - acc: 0.9978     
Epoch 984/1000
1340/1340 [==============================] - 0s - loss: 0.0796 - acc: 0.9985     
Epoch 985/1000
1340/1340 [==============================] - 0s - loss: 0.0800 - acc: 0.9978     
Epoch 986/1000
1340/1340 [==============================] - 0s - loss: 0.0789 - acc: 0.9985     
Epoch 987/1000
1340/1340 [==============================] - 0s - loss: 0.0784 - acc: 1.0000     
Epoch 988/1000
1340/1340 [==============================] - 0s - loss: 0.0778 - acc: 0.9993     
Epoch 989/1000
1340/1340 [==============================] - 0s - loss: 0.0785 - acc: 0.9985     
Epoch 990/1000
1340/1340 [==============================] - 0s - loss: 0.0806 - acc: 0.9978     
Epoch 991/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9985     
Epoch 992/1000
1340/1340 [==============================] - 0s - loss: 0.0801 - acc: 0.9985     
Epoch 993/1000
1340/1340 [==============================] - 0s - loss: 0.0786 - acc: 0.9993     
Epoch 994/1000
1340/1340 [==============================] - 0s - loss: 0.0810 - acc: 0.9970     
Epoch 995/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9978     
Epoch 996/1000
1340/1340 [==============================] - 0s - loss: 0.0776 - acc: 1.0000     
Epoch 997/1000
1340/1340 [==============================] - 0s - loss: 0.0769 - acc: 1.0000     
Epoch 998/1000
1340/1340 [==============================] - 0s - loss: 0.0799 - acc: 0.9985     
Epoch 999/1000
1340/1340 [==============================] - 0s - loss: 0.0770 - acc: 1.0000     
Epoch 1000/1000
1340/1340 [==============================] - 0s - loss: 0.0803 - acc: 0.9978     

In [17]:
# plotting results for generated connectomes using maximization-activation
from nilearn import plotting
%matplotlib inline
x = np.zeros((39,1))
x[5] = 1
x[30] = 1
heatmap1 = visualize_activation(model,layer_idx=-1, filter_indices=1,input_range = (0.,0.1))[:,:,0]
heatmap0 = visualize_activation(model,layer_idx=-1, filter_indices=0,input_range = (0.,0.1))[:,:,0]
plotting.plot_connectome(heatmap1.T+heatmap1,msdl_coords,title="reconstructed edges focal injury at node 5",edge_threshold = '98%',node_color=x)
plotting.plot_connectome(heatmap0.T+heatmap0,msdl_coords,title="reconstructed edges focal injury at node 30",edge_threshold = '98%',node_color=x)


/home/amine/anaconda2/lib/python2.7/site-packages/nilearn/plotting/displays.py:1286: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if node_color == 'auto':
Out[17]:
<nilearn.plotting.displays.OrthoProjector at 0x7f595004f890>

Utility functions for automating scripts


In [18]:
def construct_dataset(mean_connectome,first_injury_location, second_injury_location,noise_weight=0.0625):
    """
    This function takes the mean connectome and the locations of the injuries and constructs a dataset of two classes
    each class corresponds two a connectome injured at either the first location or the second.
    prams : 
        - mean_connectome : a mean connectome of some dataset functionnal or structural (np.array)
        - first_injury_location : integer representing the first region location
        - second_injury_location : integer representing the second region location
    returns : tuple (X,Y)
        - X : connectomes generated by introducing a focal injury at region 1 or 2
        - Y : categorical array for each connectome representing the class 1 or 2
    """
    S = generate_injury_signatures(X_mn=base_connectome,r_state=r_state,sig_indexes=[first_injury_location])
    X1,Y = sample_injury_strengths(1000,base_connectome,S,noise_weight)
    S = generate_injury_signatures(X_mn=base_connectome,r_state=r_state,sig_indexes=[second_injury_location])
    X2,Y = sample_injury_strengths(1000,base_connectome,S,noise_weight)
    X = np.concatenate([X1,X2],axis=0)
    X = X.reshape(X.shape[0],X.shape[2],X.shape[3],1)
    Y1 = np.array([1]*1000)
    Y2 = np.array([0]*1000)
    Y = np.concatenate([Y1,Y2],axis=0)
    Y = to_categorical(Y,2)
    return X,Y

def plot_activation_maximization_result(model,first_injury_location,second_injury_location,thresholds):
    """
    model must be trained and the params first_injury_location and second_injury_location 
    must be the same as in the construct_dataset function.
    """
    from nilearn import plotting
    %matplotlib inline
    x = np.zeros((39,1))
    x[first_injury_location] = 1
    x[second_injury_location] = 1
    heatmap1 = visualize_activation(model,layer_idx=-1, filter_indices=1,input_range = (0.,0.1))[:,:,0]
[]    heatmap0 = visualize_activation(model,layer_idx=-1, filter_indices=0,input_range = (0.,0.1))[:,:,0]
    for t in thresholds :
        plotting.plot_connectome(heatmap1.T+heatmap1,msdl_coords,title="reconstructed edges focal injury at node "+str(first_injury_location)+" threshold = "+str(t),edge_threshold = str(t)+"%",node_color=x)
        plotting.plot_connectome(heatmap0.T+heatmap0,msdl_coords,title="reconstructed edges focal injury at node "+str(second_injury_location)+" threshold = "+str(t),edge_threshold =  str(t)+"%",node_color=x)
# example
plot_activation_maximization_result(model,5,30,[95,97,98,99])