## Subsurface Data Analytics

## Artificial Neural Networks for Prediction in Python

#### Honggeun Jo, Graduate Student, The University of Texas at Austin

##### [LinkedIn](https://www.linkedin.com/in/honggeun-jo/?originalSubdomain=kr) | [Twitter](https://twitter.com/HonggeunJ)

#### Michael Pyrcz, Associate Professor, University of Texas at Austin

##### [Twitter](https://twitter.com/geostatsguy) | [GitHub](https://github.com/GeostatsGuy) | [Website](http://michaelpyrcz.com) | [GoogleScholar](https://scholar.google.com/citations?user=QVZ20eQAAAAJ&hl=en&oi=ao) | [Book](https://www.amazon.com/Geostatistical-Reservoir-Modeling-Michael-Pyrcz/dp/0199731446) | [YouTube](https://www.youtube.com/channel/UCLqEr-xV-ceHdXXXrTId5ig)  | [LinkedIn](https://www.linkedin.com/in/michael-pyrcz-61a648a1) | [GeostatsPy](https://github.com/GeostatsGuy/GeostatsPy)

### From PGE 383 Exercise: Support Vector Machine for Subsurface Modeling in Python

Here's a simple workflow, demonstration of neural networks for subsurface modeling workflows. This should help you get started with building subsurface models that use data analytics and machine learning. Here's some basic details about neural networks.

#### Neural Networks

Machine learning method for supervised learning for classification and regression analysis.  Here are some key aspects of support vector machines.

**Basic Design** *"...a computing system made up of a number of simple, highly interconnected processing elements, which process information by their dynamic state response to external inputs."* Caudill (1989).

**Nature-inspire Computing** based on the neuronal structure in the brain, including many interconnected simple, processing units, known as nodes that are capable of complicated emergent pattern detection due to a large number of nodes and interconnectivity.

**Training and Testing** just like and other predictive model (e.g. linear regression, decision trees and support vector machines) we perform training to fit parameters and testing to tune hyper parameters.

**Parameters** are the weights applied to each connection and a bias term applied to each node.  For a single node artificial neural network, we could compare the weights to the $\beta$ slope term and the bias to the $\beta_{0}$ intercept term.

\begin{equation}
Y = \beta X + \beta_0
\end{equation}

the number of parameters increases rapidly as we increase the number of nodes and the connectivity between the nodes.

**Layers** the typical artificial neural net is structured with an **input layer**, with one node for each $m$ predictor feature, $X_1,\ldots,X_m$. There is an **ouput layer**, with one node for each $r$ response feature, $Y_1,\ldots,Y_r$.  There may be one or more layers of nodes between the input and output layers, known as **hidden layer(s)**.

**Connections** are the linkages between the nodes in adjacent layers.  For example, in a fully connected artificial neural network, all the input nodes are connected to all of the nodes in the first layer, then all of the nodes in the first layer are connected to the next layer and so forth. Each connection includes a weight parameter as indicated above.

**Nodes** receive the weighted signal from the connected previous layer nodes, sum and then apply this result to the **activation** function in the node. Some example activation functions include:

* **Binary** the node fires or not.  This is represented by a Heaviside step function.

* **Identify** the input is passed to the output $f(x) = x$

* **Linear** the node passes a signal that increases linearly with the weighted input.

* **Logistic** also known as sigmoid or soft step $f(x) = \frac{1}{1+e^{-x}}$

the result of the linearly weighted inputs applied to the nonlinear activation is output from the node to the next layer of connected nodes.

**Training Cycles / Epochs** include the presentation of new data, forward application of the current prediction model to make estimates, calculation of error and then backpropagation of error to correct the network weights to reduce the error.

**Batch** is the set of training data drawn to train for each epoch. There is a trade-off, a larger batch results in more computational time per epoch, but a more accurate estimate of the error to adjust the weights.  Smaller batches result in a nosier estimate of the error, but faster epochs, this results in faster learning and even possibly more robust models.

**Local Minimums** if one calculated the error hypersurface for a range of model parameters it would be hyparabolic, there is a global minimium error solution.  But this error hyper surface is rough and it is possible to be stuck in a local minimum. **Learning Rate** and **Mommentum** coefficients are introduced to avoid getting stuck in local minimums.

* **Mommentum** is a hyperparameter to control the use of information from the weight update over the last epoch for consideration in the current epoch.  This can be accomplished with an update vector, $v_i$, a mommentum parameter, $\alpha$, to calculate the current weight update, $v_{i+1}$ given the new update $\theta_{i+1}$.

\begin{equation}
v_{i+1} = \alpha v_i + \theta_{i+1}
\end{equation}

* **Learning Rate** is a hyperparameter that controls the adjustment of the weights in response to the gradient indicated by backpropagation of error

##### Applications to subsurface modeling

We demonstrate the estimation of porosity between wells from seismic accoustic impedance.

* modeling a nonlinear relationship between acoustic impedance and porosity

#### Limitations of Neural Network Estimation

Since we demonstrate the use of a neural network to estimate porosity inter-well from seismic, we should comment on limitations of neural networks for estimation:

* does not honor the well data

* does not honor the histogram of the data

* does not honor spaital correlation

* does not honor the multivariate relationship

* generally low interpretability models

* requires a large number of data for effective training

* high model complexity with high model variance

#### Workflow Goals

Learn the basics of machine learning in python to predict subsurface features. This includes:

* Loading and visualizing sample data
* Trying out neural nets

#### Objective

In the PGE 383: Subsurface Machine Learning Class, I want to provide hands-on experience with building subsurface modeling workflows. Python provides an excellent vehicle to accomplish this. I have coded a package called GeostatsPy with GSLIB: Geostatistical Library (Deutsch and Journel, 1998) functionality that provides basic building blocks for building subsurface modeling workflows.

The objective is to remove the hurdles of subsurface modeling workflow construction by providing building blocks and sufficient examples. This is not a coding class per se, but we need the ability to 'script' workflows working with numerical methods.

#### Getting Started

Here's the steps to get setup in Python with the GeostatsPy package:

1. Install Anaconda 3 on your machine (https://www.anaconda.com/download/).
2. From Anaconda Navigator (within Anaconda3 group), go to the environment tab, click on base (root) green arrow and open a terminal.
3. In the terminal type: pip install geostatspy.
4. Open Jupyter and in the top block get started by copy and pasting the code block below from this Jupyter Notebook to start using the geostatspy functionality.

You will need to copy the data file to your working directory.  They are available here:

* Tabular data - 12_sample_data.csv found [here](https://github.com/GeostatsGuy/GeoDataSets/blob/master/12_sample_data.csv).

There are exampled below with these functions. You can go here to see a list of the available functions, https://git.io/fh4eX, other example workflows and source code.

#### Import Required Packages

We will also need some standard packages. These should have been installed with Anaconda 3.

```python
import geostatspy.GSLIB as GSLIB  # GSLIB utilies, visualization and wrapper
import geostatspy.geostats as geostats  # GSLIB methods convert to Python
```

We will also need some standard packages. These should have been installed with Anaconda 3.

```python
import numpy as np  # ndarrys for gridded data
import pandas as pd  # DataFrames for tabular data
import os  # set working directory, run executables
import matplotlib.pyplot as plt  # for plotting
import seaborn as sns  # for plotting
import warnings  # supress warnings from seaborn pairplot
from sklearn.model_selection import (
    train_test_split,
)  # train / test DatFrame split
```

We will also need the following packages to train and test our artificial neural nets:

* Tensorflow - open source machine learning

* Keras - high level application programing interface (API) to build and train models

More information is available at [tensorflow install](https://www.tensorflow.org/install).

* This workflow was designed with tensorflow version 1.13.1 and does not work with version 2.0.0 alpha.

To check your current version of tensorflow you could run the next block of code.

```python
import tensorflow as tf

tf.__version__  # check the installed version of tensorflow
```

    '1.13.1'

Let's import all of the tensorflow and keras methods that we will need in our workflow.

```python
import tensorflow as tf
from keras.models import Sequential, load_model
from keras.layers.core import Dense, Dropout, Activation
from keras.utils import np_utils
import keras
from tensorflow.python.keras import backend as k
```

    Using TensorFlow backend.

#### Set the working directory

I always like to do this so I don't lose files and to simplify subsequent read and writes (avoid including the full address each time).

```python
os.chdir("C:/PGE383")
```

#### Loading Data
Let's load the provided multivariate, spatial dataset '12_sample_data.csv'.  It is a comma delimited file with:

* X and Y coordinates ($m$)
* facies 0 and 1
* porosity (fraction)
* permeability ($mD$)
* acoustic impedance ($\frac{kg}{m^3} \cdot \frac{m}{s} \cdot 10^3$).

We load it with the pandas 'read_csv' function into a data frame we called 'df' and then preview it to make sure it loaded correctly.

**Python Tip: using functions from a package** just type the label for the package that we declared at the beginning:

```python
import pandas as pd
```

so we can access the pandas function 'read_csv' with the command:

```python
pd.read_csv()
```

but read csv has required input parameters. The essential one is the name of the file. For our circumstance all the other default parameters are fine. If you want to see all the possible parameters for this function, just go to the docs [here](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html).

* The docs are always helpful
* There is often a lot of flexibility for Python functions, possible through using various inputs parameters

also, the program has an output, a pandas DataFrame loaded from the data.  So we have to specficy the name / variable representing that new object.

```python
df = pd.read_csv("12_sample_data.csv")
```

Let's run this command to load the data and then look at the resulting DataFrame to ensure that we loaded it.

```python
df = pd.read_csv("12_sample_data.csv")  # load our data table (wrong name!)
df = df.sample(frac=0.30, random_state=73073)
df = df.reset_index()
df["logPerm"] = np.log10(df["Perm"].values)
```

Let's add a facies label for shale and sand.

```python
df["Facies_Label"] = np.zeros(len(df))
df["Facies_Label"] = np.where(df["Facies"] == 1, "Sand", "Shale")
```

Let's get a quick preview of our new DataFrame, 'df' with the built in function.

```python
df.head()
```

```python
df.head(n=13)
```

      index
      X
      Y
      Facies
      Porosity
      Perm
      AI
      logPerm
      Facies_Label

      0
      72
      250
      50
      0
      0.139637
      0.347182
      4747.274043
      -0.459442
      Shale

      1
      153
      650
      750
      0
      0.170732
      10.720560
      4535.625583
      1.030217
      Shale

      2
      258
      80
      669
      1
      0.244345
      3222.716042
      2696.102930
      3.508222
      Sand

      3
      56
      200
      150
      0
      0.167125
      3.042590
      5500.997419
      0.483243
      Shale

      4
      303
      60
      929
      1
      0.216253
      400.298484
      3959.934912
      2.602384
      Sand

      5
      374
      750
      699
      0
      0.159171
      9.224292
      5263.064063
      0.964933
      Shale

      6
      333
      340
      549
      0
      0.170881
      84.471492
      2918.232227
      1.926710
      Shale

      7
      1
      50
      850
      1
      0.237154
      39.837129
      3074.562617
      1.600288
      Sand

      8
      54
      200
      250
      1
      0.188043
      57.804784
      4997.078597
      1.761964
      Sand

      9
      311
      250
      579
      1
      0.215039
      625.510541
      2693.691341
      2.796235
      Sand

      10
      8
      50
      450
      1
      0.200389
      265.636019
      3454.389302
      2.424287
      Sand

      11
      269
      540
      859
      0
      0.173662
      39.910675
      3414.962471
      1.601089
      Shale

      12
      279
      580
      779
      0
      0.168371
      11.171392
      3646.918994
      1.048107
      Shale

#### Summary Statistics for Tabular Data

There are a lot of efficient methods to calculate summary statistics from tabular data in DataFrames. The describe command provides count, mean, minimum, maximum, and quartiles all in a nice data table. We use transpose just to flip the table so that features are on the rows and the statistics are on the columns.

```python
df.describe().transpose()
```

      count
      mean
      std
      min
      25%
      50%
      75%
      max

      index
      144.0
      261.048611
      136.830267
      1.000000
      144.750000
      270.000000
      381.250000
      478.000000

      X
      144.0
      449.375000
      263.691435
      0.000000
      242.500000
      400.000000
      650.000000
      980.000000

      Y
      144.0
      542.979167
      289.228936
      19.000000
      300.000000
      579.000000
      800.000000
      979.000000

      Facies
      144.0
      0.659722
      0.475456
      0.000000
      0.000000
      1.000000
      1.000000
      1.000000

      Porosity
      144.0
      0.190700
      0.031972
      0.131230
      0.166621
      0.188733
      0.217234
      0.256172

      Perm
      144.0
      510.036736
      1136.459068
      0.039555
      6.950509
      56.886770
      356.658709
      7452.343369

      AI
      144.0
      3746.825725
      793.196589
      1961.600397
      3167.631744
      3668.526774
      4244.264532
      6194.573653

      logPerm
      144.0
      1.646059
      1.210694
      -1.402796
      0.841941
      1.754955
      2.552252
      3.872293

From this table we set some reasonable feature ranges for plotting.

```python
pormin = 0.13
pormax = 0.26  # porosity min and max
permmin = 0.01
permmax = 3000  # permeability min and max
AImin = 1000.0
AImax = 8000  # acoustic impedance min and max
Fmin = 0
Fmax = 1  # facies min and max
cmap = plt.cm.plasma  # color map for plotting
```

#### Seismically-Derived Map

Let's load a seismically-derived map of acoustic impedance.

* This seismic acoustic impedance matches the well data acoustic impedance at the well locations

* This seismic data has better coverage than the well data, but with larger scale and error

```python
seismic = np.loadtxt(open("12_AI.csv", "rb"), delimiter=",")
```

Let's set the map parameters:

* X min and max

* Y min and max

* number of cells in the X and Y directions

* isotropic cell size

and then plot the loaded seismic map.

```python
xmin = 0.0
xmax = 1000.0  # range of x values
ymin = 0.0
ymax = 1000.0  # range of y values
ny = 100
nx = 100  # number of cell in Y and X
cell_size = 10.0
# grid cell size

plt.subplot(111)
GSLIB.pixelplt_st(
    seismic,
    xmin,
    xmax,
    ymin,
    ymax,
    cell_size,
    AImin,
    AImax,
    "Acoustic Impedance",
    "X(m)",
    "Y(m)",
    "Acoustic Impedance (kg/m2s*10^3)",
    cmap,
)
plt.subplots_adjust(
    left=0.0, bottom=0.0, right=1.2, top=1.2, wspace=0.2, hspace=0.2
)
plt.show()
```

#### Extract Variables of Interest

Let's extract the facies, porosity, log permeability and acoustic impedance.

* the extracted DataFrame subset is a shallow copy, any changes in DataFrame 'df_subset' update the same entries in 'df'.

```python
df_subset = df.iloc[:, [3, 4, 7, 6]]
```

Always good to preview the DataFrame everytime we work with it to make sure it is correct.

```python
df_subset.head(n=13)
```

      Facies
      Porosity
      logPerm
      AI

      0
      0
      0.139637
      -0.459442
      4747.274043

      1
      0
      0.170732
      1.030217
      4535.625583

      2
      1
      0.244345
      3.508222
      2696.102930

      3
      0
      0.167125
      0.483243
      5500.997419

      4
      1
      0.216253
      2.602384
      3959.934912

      5
      0
      0.159171
      0.964933
      5263.064063

      6
      0
      0.170881
      1.926710
      2918.232227

      7
      1
      0.237154
      1.600288
      3074.562617

      8
      1
      0.188043
      1.761964
      4997.078597

      9
      1
      0.215039
      2.796235
      2693.691341

      10
      1
      0.200389
      2.424287
      3454.389302

      11
      0
      0.173662
      1.601089
      3414.962471

      12
      0
      0.168371
      1.048107
      3646.918994

#### Multivariate Relationships

Before we build a predictive model, it is a good idea to attempt to understand the multivariate relationships between the variables. Let's calculate a matrix scatter plots to understand how the data parameters are correlated to each other, 2 variables at a time:

* linearility vs. non-linearity

* homo- vs. heteroscedasticity,

* constraints

```python
warnings.filterwarnings("ignore")  # supress warning from the seaborn.pairplot
sns.pairplot(df_subset, hue="Facies")
sns.set(style="ticks")
plt.show()
```

#### Data Normalization

We must normalize the features before we apply them in a neural network model.

* We will set the features to range from -1 to 1.

These are the motivations for this normalization:

* remove effect of scale of different type of data (i.e., acoustic impedance varies between 2000~6000 but porosity only varies between 0~0.3)

* activation functions in Neural networks have more sensivity when the values of nodes are closer to 0.0 (i.e., results in higher gradient and improves backpropagation in training)

Let's normalize each feature.

* It is easy to backtransform given we keep track of the original min and max values

```python
por_min = df_subset["Porosity"].min()
por_max = df_subset["Porosity"].max()
logperm_min = df_subset["logPerm"].min()
logperm_max = df_subset["logPerm"].max()
AI_min = df_subset["AI"].min()
AI_max = df_subset["AI"].max()

df_subset["norm_Porosity"] = (df_subset["Porosity"] - por_min) / (
    por_max - por_min
) * 2 - 1
df_subset["norm_logPerm"] = (df_subset["logPerm"] - logperm_min) / (
    logperm_max - logperm_min
) * 2 - 1
df_subset["norm_AI"] = (df_subset["AI"] - AI_min) / (AI_max - AI_min) * 2 - 1
```

Let's check the update to our DataFrame with a quick preview.

```python
df_subset.head(n=13)
```

      Facies
      Porosity
      logPerm
      AI
      norm_Porosity
      norm_logPerm
      norm_AI

      0
      0
      0.139637
      -0.459442
      4747.274043
      -0.865422
      -0.642337
      0.316178

      1
      0
      0.170732
      1.030217
      4535.625583
      -0.367672
      -0.077546
      0.216178

      2
      1
      0.244345
      3.508222
      2696.102930
      0.810690
      0.861966
      -0.652961

      3
      0
      0.167125
      0.483243
      5500.997419
      -0.425413
      -0.284926
      0.672298

      4
      1
      0.216253
      2.602384
      3959.934912
      0.361002
      0.518526
      -0.055825

      5
      0
      0.159171
      0.964933
      5263.064063
      -0.552734
      -0.102298
      0.559879

      6
      0
      0.170881
      1.926710
      2918.232227
      -0.365287
      0.262351
      -0.548010

      7
      1
      0.237154
      1.600288
      3074.562617
      0.695581
      0.138591
      -0.474146

      8
      1
      0.188043
      1.761964
      4997.078597
      -0.090559
      0.199889
      0.434206

      9
      1
      0.215039
      2.796235
      2693.691341
      0.341574
      0.592023
      -0.654101

      10
      1
      0.200389
      2.424287
      3454.389302
      0.107058
      0.451002
      -0.294685

      11
      0
      0.173662
      1.601089
      3414.962471
      -0.320773
      0.138895
      -0.313314

      12
      0
      0.168371
      1.048107
      3646.918994
      -0.405462
      -0.070763
      -0.203719

It is also a good idea to check the summary statistics.

* All continuous features should now range from -1.0 to 1.0

```python
df_subset.describe().transpose()
```

      count
      mean
      std
      min
      25%
      50%
      75%
      max

      Facies
      144.0
      0.659722
      0.475456
      0.000000
      0.000000
      1.000000
      1.000000
      1.000000

      Porosity
      144.0
      0.190700
      0.031972
      0.131230
      0.166621
      0.188733
      0.217234
      0.256172

      logPerm
      144.0
      1.646059
      1.210694
      -1.402796
      0.841941
      1.754955
      2.552252
      3.872293

      AI
      144.0
      3746.825725
      793.196589
      1961.600397
      3167.631744
      3668.526774
      4244.264532
      6194.573653

      norm_Porosity
      144.0
      -0.048027
      0.511789
      -1.000000
      -0.433483
      -0.079520
      0.376700
      1.000000

      norm_logPerm
      144.0
      0.155945
      0.459023
      -1.000000
      -0.148929
      0.197231
      0.499519
      1.000000

      norm_AI
      144.0
      -0.156515
      0.374770
      -1.000000
      -0.430173
      -0.193509
      0.078516
      1.000000

#### Separation of Training and Testing Data

We also need to split our data into training / testing datasets so that we:

* can train our neural networks using training data

* while testing their performance with validating data.

```python
X = df_subset.iloc[
    :, [6]
]  # extract the predictor feature - acoustic impedance
y = df_subset.iloc[:, [4]]  # extract the response feature - porosity
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=73073
)
```

Let's visualize are train and test data split on a single scatter plot.

* we want to make sure it is fair

* ensure that the test samples are not clustered or too far away from the training data.

```python
plt.subplot(121)
plt.plot(
    X_train["norm_AI"].values,
    y_train["norm_Porosity"].values,
    "o",
    markerfacecolor="red",
    markeredgecolor="black",
    alpha=0.4,
    label="Train",
)
plt.plot(
    X_test["norm_AI"].values,
    y_test["norm_Porosity"].values,
    "o",
    markerfacecolor="blue",
    markeredgecolor="black",
    alpha=0.4,
    label="Test",
)
plt.legend(loc="upper right")
plt.title("Train and Test: Porosity vs. Acoustic Impedance")
plt.ylabel("Porosity (Normalized)")
plt.xlabel("Acoustic Impedance (Normalized)")
plt.xlim(-1, 1)
plt.ylim(-1, 1)

plt.subplots_adjust(
    left=0.0, bottom=0.0, right=2.2, top=1.2, wspace=0.2, hspace=0.2
)
plt.show()
```

#### Build and Train a Simple Neural Network

For our first model let's try something very simple.

* 1 predictor feature - acoustic impedance

* 1 responce feature - porosity

We will build a model to predict porosity from acoustic impedance over all locations in our model $\bf{u} \in AOI$.

\begin{equation}
\phi(\bf{u}) = \hat{f}(AI(\bf{u})
\end{equation}

We will use this model to inform porosity between the wells.

```python
# Build Neural Network for prediction model (input: AI - > Output: Porosity)
model_1 = Sequential(
    [
        Dense(1, activation="relu", input_shape=(1,)),
        Dense(3, activation="relu"),
        Dense(1, activation="tanh"),
    ]
)
```

We have specified a simple neural net with:

* 1 input node

* 3 nodes in the hidden layer

* 1 output node

Now we specify the optimization method and the related hyperparameters (e.g.,learning rate, etc)
further information of Keras optimizers are available [here](https://keras.io/optimizers).

```python
keras.optimizers.Adam(
    lr=0.003, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False
)

model_1.compile(optimizer="adam", loss="mse", metrics=["accuracy"])
```

We are ready to supply our normalized predictor feature to predict the normalized responce feature.

```python
hist_1 = model_1.fit(
    X_train,
    y_train,
    batch_size=5,
    epochs=300,
    validation_data=(X_test, y_test),
)
```

    Train on 115 samples, validate on 29 samples
    Epoch 1/300
    115/115 [==============================] - 0s 4ms/step - loss: 0.2258 - acc: 0.0000e+00 - val_loss: 0.2715 - val_acc: 0.0000e+00
    Epoch 2/300
    115/115 [==============================] - 0s 270us/step - loss: 0.2179 - acc: 0.0000e+00 - val_loss: 0.2682 - val_acc: 0.0000e+00
    Epoch 3/300
    115/115 [==============================] - 0s 244us/step - loss: 0.2125 - acc: 0.0000e+00 - val_loss: 0.2650 - val_acc: 0.0000e+00
    Epoch 4/300
    115/115 [==============================] - 0s 239us/step - loss: 0.2080 - acc: 0.0000e+00 - val_loss: 0.2598 - val_acc: 0.0000e+00
    Epoch 5/300
    115/115 [==============================] - 0s 217us/step - loss: 0.2046 - acc: 0.0000e+00 - val_loss: 0.2578 - val_acc: 0.0000e+00
    Epoch 6/300
    115/115 [==============================] - 0s 226us/step - loss: 0.2013 - acc: 0.0000e+00 - val_loss: 0.2540 - val_acc: 0.0000e+00
    Epoch 7/300
    115/115 [==============================] - 0s 235us/step - loss: 0.1994 - acc: 0.0000e+00 - val_loss: 0.2500 - val_acc: 0.0000e+00
    Epoch 8/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1966 - acc: 0.0000e+00 - val_loss: 0.2494 - val_acc: 0.0000e+00
    Epoch 9/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1936 - acc: 0.0000e+00 - val_loss: 0.2446 - val_acc: 0.0000e+00
    Epoch 10/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1915 - acc: 0.0000e+00 - val_loss: 0.2420 - val_acc: 0.0000e+00
    Epoch 11/300
    115/115 [==============================] - 0s 218us/step - loss: 0.1895 - acc: 0.0000e+00 - val_loss: 0.2394 - val_acc: 0.0000e+00
    Epoch 12/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1886 - acc: 0.0000e+00 - val_loss: 0.2358 - val_acc: 0.0000e+00
    Epoch 13/300
    115/115 [==============================] - 0s 217us/step - loss: 0.1860 - acc: 0.0000e+00 - val_loss: 0.2334 - val_acc: 0.0000e+00
    Epoch 14/300
    115/115 [==============================] - ETA: 0s - loss: 0.2748 - acc: 0.0000e+0 - 0s 209us/step - loss: 0.1843 - acc: 0.0000e+00 - val_loss: 0.2319 - val_acc: 0.0000e+00
    Epoch 15/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1835 - acc: 0.0000e+00 - val_loss: 0.2304 - val_acc: 0.0000e+00
    Epoch 16/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1823 - acc: 0.0000e+00 - val_loss: 0.2278 - val_acc: 0.0000e+00
    Epoch 17/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1812 - acc: 0.0000e+00 - val_loss: 0.2260 - val_acc: 0.0000e+00
    Epoch 18/300
    115/115 [==============================] - 0s 213us/step - loss: 0.1803 - acc: 0.0000e+00 - val_loss: 0.2261 - val_acc: 0.0000e+00
    Epoch 19/300
    115/115 [==============================] - 0s 222us/step - loss: 0.1792 - acc: 0.0000e+00 - val_loss: 0.2243 - val_acc: 0.0000e+00
    Epoch 20/300
    115/115 [==============================] - 0s 226us/step - loss: 0.1794 - acc: 0.0000e+00 - val_loss: 0.2217 - val_acc: 0.0000e+00
    Epoch 21/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1779 - acc: 0.0000e+00 - val_loss: 0.2229 - val_acc: 0.0000e+00
    Epoch 22/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1771 - acc: 0.0000e+00 - val_loss: 0.2196 - val_acc: 0.0000e+00
    Epoch 23/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1758 - acc: 0.0000e+00 - val_loss: 0.2191 - val_acc: 0.0000e+00
    Epoch 24/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1752 - acc: 0.0000e+00 - val_loss: 0.2179 - val_acc: 0.0000e+00
    Epoch 25/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1746 - acc: 0.0000e+00 - val_loss: 0.2180 - val_acc: 0.0000e+00
    Epoch 26/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1739 - acc: 0.0000e+00 - val_loss: 0.2172 - val_acc: 0.0000e+00
    Epoch 27/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1732 - acc: 0.0000e+00 - val_loss: 0.2150 - val_acc: 0.0000e+00
    Epoch 28/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1730 - acc: 0.0000e+00 - val_loss: 0.2139 - val_acc: 0.0000e+00
    Epoch 29/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1726 - acc: 0.0000e+00 - val_loss: 0.2145 - val_acc: 0.0000e+00
    Epoch 30/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1722 - acc: 0.0000e+00 - val_loss: 0.2124 - val_acc: 0.0000e+00
    Epoch 31/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1716 - acc: 0.0000e+00 - val_loss: 0.2123 - val_acc: 0.0000e+00
    Epoch 32/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1727 - acc: 0.0000e+00 - val_loss: 0.2136 - val_acc: 0.0000e+00
    Epoch 33/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1710 - acc: 0.0000e+00 - val_loss: 0.2109 - val_acc: 0.0000e+00
    Epoch 34/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1703 - acc: 0.0000e+00 - val_loss: 0.2117 - val_acc: 0.0000e+00
    Epoch 35/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1702 - acc: 0.0000e+00 - val_loss: 0.2105 - val_acc: 0.0000e+00
    Epoch 36/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1695 - acc: 0.0000e+00 - val_loss: 0.2109 - val_acc: 0.0000e+00
    Epoch 37/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1695 - acc: 0.0000e+00 - val_loss: 0.2120 - val_acc: 0.0000e+00
    Epoch 38/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1690 - acc: 0.0000e+00 - val_loss: 0.2102 - val_acc: 0.0000e+00
    Epoch 39/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1690 - acc: 0.0000e+00 - val_loss: 0.2096 - val_acc: 0.0000e+00
    Epoch 40/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1690 - acc: 0.0000e+00 - val_loss: 0.2084 - val_acc: 0.0000e+00
    Epoch 41/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1691 - acc: 0.0000e+00 - val_loss: 0.2094 - val_acc: 0.0000e+00
    Epoch 42/300
    115/115 [==============================] - 0s 209us/step - loss: 0.1683 - acc: 0.0000e+00 - val_loss: 0.2096 - val_acc: 0.0000e+00
    Epoch 43/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1680 - acc: 0.0000e+00 - val_loss: 0.2080 - val_acc: 0.0000e+00
    Epoch 44/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1676 - acc: 0.0000e+00 - val_loss: 0.2089 - val_acc: 0.0000e+00
    Epoch 45/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1676 - acc: 0.0000e+00 - val_loss: 0.2073 - val_acc: 0.0000e+00
    Epoch 46/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1681 - acc: 0.0000e+00 - val_loss: 0.2100 - val_acc: 0.0000e+00
    Epoch 47/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1668 - acc: 0.0000e+00 - val_loss: 0.2081 - val_acc: 0.0000e+00
    Epoch 48/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1671 - acc: 0.0000e+00 - val_loss: 0.2076 - val_acc: 0.0000e+00
    Epoch 49/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1667 - acc: 0.0000e+00 - val_loss: 0.2075 - val_acc: 0.0000e+00
    Epoch 50/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1667 - acc: 0.0000e+00 - val_loss: 0.2068 - val_acc: 0.0000e+00
    Epoch 51/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1665 - acc: 0.0000e+00 - val_loss: 0.2070 - val_acc: 0.0000e+00
    Epoch 52/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1664 - acc: 0.0000e+00 - val_loss: 0.2059 - val_acc: 0.0000e+00
    Epoch 53/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1660 - acc: 0.0000e+00 - val_loss: 0.2068 - val_acc: 0.0000e+00
    Epoch 54/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1657 - acc: 0.0000e+00 - val_loss: 0.2068 - val_acc: 0.0000e+00
    Epoch 55/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1658 - acc: 0.0000e+00 - val_loss: 0.2060 - val_acc: 0.0000e+00
    Epoch 56/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1658 - acc: 0.0000e+00 - val_loss: 0.2062 - val_acc: 0.0000e+00
    Epoch 57/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1653 - acc: 0.0000e+00 - val_loss: 0.2058 - val_acc: 0.0000e+00
    Epoch 58/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1658 - acc: 0.0000e+00 - val_loss: 0.2039 - val_acc: 0.0000e+00
    Epoch 59/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1660 - acc: 0.0000e+00 - val_loss: 0.2059 - val_acc: 0.0000e+00
    Epoch 60/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1654 - acc: 0.0000e+00 - val_loss: 0.2038 - val_acc: 0.0000e+00
    Epoch 61/300
    115/115 [==============================] - 0s 204us/step - loss: 0.1648 - acc: 0.0000e+00 - val_loss: 0.2049 - val_acc: 0.0000e+00
    Epoch 62/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1650 - acc: 0.0000e+00 - val_loss: 0.2043 - val_acc: 0.0000e+00
    Epoch 63/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1649 - acc: 0.0000e+00 - val_loss: 0.2034 - val_acc: 0.0000e+00
    Epoch 64/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1657 - acc: 0.0000e+00 - val_loss: 0.2065 - val_acc: 0.0000e+00
    Epoch 65/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1649 - acc: 0.0000e+00 - val_loss: 0.2034 - val_acc: 0.0000e+00
    Epoch 66/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1644 - acc: 0.0000e+00 - val_loss: 0.2033 - val_acc: 0.0000e+00
    Epoch 67/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1643 - acc: 0.0000e+00 - val_loss: 0.2038 - val_acc: 0.0000e+00
    Epoch 68/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1641 - acc: 0.0000e+00 - val_loss: 0.2031 - val_acc: 0.0000e+00
    Epoch 69/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1673 - acc: 0.0000e+00 - val_loss: 0.2058 - val_acc: 0.0000e+00
    Epoch 70/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2018 - val_acc: 0.0000e+00
    Epoch 71/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1642 - acc: 0.0000e+00 - val_loss: 0.2031 - val_acc: 0.0000e+00
    Epoch 72/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2025 - val_acc: 0.0000e+00
    Epoch 73/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.2026 - val_acc: 0.0000e+00
    Epoch 74/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1642 - acc: 0.0000e+00 - val_loss: 0.2037 - val_acc: 0.0000e+00
    Epoch 75/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.2019 - val_acc: 0.0000e+00
    Epoch 76/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1649 - acc: 0.0000e+00 - val_loss: 0.2054 - val_acc: 0.0000e+00
    Epoch 77/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2027 - val_acc: 0.0000e+00
    Epoch 78/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1651 - acc: 0.0000e+00 - val_loss: 0.2038 - val_acc: 0.0000e+00
    Epoch 79/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1648 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 80/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.2017 - val_acc: 0.0000e+00
    Epoch 81/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2027 - val_acc: 0.0000e+00
    Epoch 82/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.2014 - val_acc: 0.0000e+00
    Epoch 83/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2034 - val_acc: 0.0000e+00
    Epoch 84/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2016 - val_acc: 0.0000e+00
    Epoch 85/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2011 - val_acc: 0.0000e+00
    Epoch 86/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2035 - val_acc: 0.0000e+00
    Epoch 87/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.2029 - val_acc: 0.0000e+00
    Epoch 88/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1643 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 89/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2011 - val_acc: 0.0000e+00
    Epoch 90/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2043 - val_acc: 0.0000e+00
    Epoch 91/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1650 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 92/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2019 - val_acc: 0.0000e+00
    Epoch 93/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2015 - val_acc: 0.0000e+00
    Epoch 94/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.2007 - val_acc: 0.0000e+00
    Epoch 95/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1645 - acc: 0.0000e+00 - val_loss: 0.2040 - val_acc: 0.0000e+00
    Epoch 96/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2012 - val_acc: 0.0000e+00
    Epoch 97/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 98/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2017 - val_acc: 0.0000e+00
    Epoch 99/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2012 - val_acc: 0.0000e+00
    Epoch 100/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2015 - val_acc: 0.0000e+00
    Epoch 101/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2002 - val_acc: 0.0000e+00
    Epoch 102/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2016 - val_acc: 0.0000e+00
    Epoch 103/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2015 - val_acc: 0.0000e+00
    Epoch 104/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2026 - val_acc: 0.0000e+00
    Epoch 105/300
    115/115 [==============================] - ETA: 0s - loss: 0.0826 - acc: 0.0000e+0 - 0s 187us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 106/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2002 - val_acc: 0.0000e+00
    Epoch 107/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2016 - val_acc: 0.0000e+00
    Epoch 108/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2007 - val_acc: 0.0000e+00
    Epoch 109/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2008 - val_acc: 0.0000e+00
    Epoch 110/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2011 - val_acc: 0.0000e+00
    Epoch 111/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 112/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 113/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1642 - acc: 0.0000e+00 - val_loss: 0.1996 - val_acc: 0.0000e+00
    Epoch 114/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 115/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1642 - acc: 0.0000e+00 - val_loss: 0.2024 - val_acc: 0.0000e+00
    Epoch 116/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 117/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2009 - val_acc: 0.0000e+00
    Epoch 118/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 119/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2012 - val_acc: 0.0000e+00
    Epoch 120/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 121/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2015 - val_acc: 0.0000e+00
    Epoch 122/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2010 - val_acc: 0.0000e+00
    Epoch 123/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 124/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1648 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 125/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 126/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2002 - val_acc: 0.0000e+00
    Epoch 127/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2003 - val_acc: 0.0000e+00
    Epoch 128/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2019 - val_acc: 0.0000e+00
    Epoch 129/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 130/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2019 - val_acc: 0.0000e+00
    Epoch 131/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 132/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1644 - acc: 0.0000e+00 - val_loss: 0.2025 - val_acc: 0.0000e+00
    Epoch 133/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 134/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2002 - val_acc: 0.0000e+00
    Epoch 135/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2016 - val_acc: 0.0000e+00
    Epoch 136/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.2000 - val_acc: 0.0000e+00
    Epoch 137/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.1991 - val_acc: 0.0000e+00
    Epoch 138/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2001 - val_acc: 0.0000e+00
    Epoch 139/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 140/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 141/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1641 - acc: 0.0000e+00 - val_loss: 0.2018 - val_acc: 0.0000e+00
    Epoch 142/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.2008 - val_acc: 0.0000e+00
    Epoch 143/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 144/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1647 - acc: 0.0000e+00 - val_loss: 0.1975 - val_acc: 0.0000e+00
    Epoch 145/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.2016 - val_acc: 0.0000e+00
    Epoch 146/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1997 - val_acc: 0.0000e+00
    Epoch 147/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2003 - val_acc: 0.0000e+00
    Epoch 148/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 149/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1641 - acc: 0.0000e+00 - val_loss: 0.2000 - val_acc: 0.0000e+00
    Epoch 150/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1648 - acc: 0.0000e+00 - val_loss: 0.1973 - val_acc: 0.0000e+00
    Epoch 151/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1641 - acc: 0.0000e+00 - val_loss: 0.2010 - val_acc: 0.0000e+00
    Epoch 152/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 153/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1985 - val_acc: 0.0000e+00
    Epoch 154/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 155/300
    115/115 [==============================] - 0s 204us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1990 - val_acc: 0.0000e+00
    Epoch 156/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2011 - val_acc: 0.0000e+00
    Epoch 157/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2000 - val_acc: 0.0000e+00
    Epoch 158/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 159/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2001 - val_acc: 0.0000e+00
    Epoch 160/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 161/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1979 - val_acc: 0.0000e+00
    Epoch 162/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.2001 - val_acc: 0.0000e+00
    Epoch 163/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 164/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 165/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 166/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 167/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1988 - val_acc: 0.0000e+00
    Epoch 168/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 169/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 170/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 171/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 172/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 173/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1998 - val_acc: 0.0000e+00
    Epoch 174/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 175/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 176/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 177/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 178/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 179/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 180/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 181/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 182/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 183/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1990 - val_acc: 0.0000e+00
    Epoch 184/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1982 - val_acc: 0.0000e+00
    Epoch 185/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2013 - val_acc: 0.0000e+00
    Epoch 186/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1992 - val_acc: 0.0000e+00
    Epoch 187/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.1992 - val_acc: 0.0000e+00
    Epoch 188/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.2012 - val_acc: 0.0000e+00
    Epoch 189/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1981 - val_acc: 0.0000e+00
    Epoch 190/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1988 - val_acc: 0.0000e+00
    Epoch 191/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 192/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 193/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1988 - val_acc: 0.0000e+00
    Epoch 194/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1992 - val_acc: 0.0000e+00
    Epoch 195/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 196/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1997 - val_acc: 0.0000e+00
    Epoch 197/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 198/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.2004 - val_acc: 0.0000e+00
    Epoch 199/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1980 - val_acc: 0.0000e+00
    Epoch 200/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1973 - val_acc: 0.0000e+00
    Epoch 201/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1991 - val_acc: 0.0000e+00
    Epoch 202/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 203/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 204/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1640 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 205/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1981 - val_acc: 0.0000e+00
    Epoch 206/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 207/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.1977 - val_acc: 0.0000e+00
    Epoch 208/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1627 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 209/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 210/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 211/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 212/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1992 - val_acc: 0.0000e+00
    Epoch 213/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1992 - val_acc: 0.0000e+00
    Epoch 214/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1976 - val_acc: 0.0000e+00
    Epoch 215/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.2008 - val_acc: 0.0000e+00
    Epoch 216/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1988 - val_acc: 0.0000e+00
    Epoch 217/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1642 - acc: 0.0000e+00 - val_loss: 0.1973 - val_acc: 0.0000e+00
    Epoch 218/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1627 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 219/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1652 - acc: 0.0000e+00 - val_loss: 0.2021 - val_acc: 0.0000e+00
    Epoch 220/300
    115/115 [==============================] - 0s 192us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1968 - val_acc: 0.0000e+00
    Epoch 221/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.1976 - val_acc: 0.0000e+00
    Epoch 222/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 223/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1981 - val_acc: 0.0000e+00
    Epoch 224/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1982 - val_acc: 0.0000e+00
    Epoch 225/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 226/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1999 - val_acc: 0.0000e+00
    Epoch 227/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1981 - val_acc: 0.0000e+00
    Epoch 228/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1994 - val_acc: 0.0000e+00
    Epoch 229/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.1990 - val_acc: 0.0000e+00
    Epoch 230/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 231/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.1990 - val_acc: 0.0000e+00
    Epoch 232/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 233/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1982 - val_acc: 0.0000e+00
    Epoch 234/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1980 - val_acc: 0.0000e+00
    Epoch 235/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1973 - val_acc: 0.0000e+00
    Epoch 236/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1982 - val_acc: 0.0000e+00
    Epoch 237/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1983 - val_acc: 0.0000e+00
    Epoch 238/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1978 - val_acc: 0.0000e+00
    Epoch 239/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 240/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1980 - val_acc: 0.0000e+00
    Epoch 241/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 242/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1966 - val_acc: 0.0000e+00
    Epoch 243/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1643 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 244/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.1977 - val_acc: 0.0000e+00
    Epoch 245/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 246/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 247/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1998 - val_acc: 0.0000e+00
    Epoch 248/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1974 - val_acc: 0.0000e+00
    Epoch 249/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.1964 - val_acc: 0.0000e+00
    Epoch 250/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 251/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1983 - val_acc: 0.0000e+00
    Epoch 252/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 253/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 254/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1974 - val_acc: 0.0000e+00
    Epoch 255/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1976 - val_acc: 0.0000e+00
    Epoch 256/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1654 - acc: 0.0000e+00 - val_loss: 0.1969 - val_acc: 0.0000e+00
    Epoch 257/300
    115/115 [==============================] - 0s 183us/step - loss: 0.1635 - acc: 0.0000e+00 - val_loss: 0.2006 - val_acc: 0.0000e+00
    Epoch 258/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1993 - val_acc: 0.0000e+00
    Epoch 259/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 260/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.1970 - val_acc: 0.0000e+00
    Epoch 261/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1626 - acc: 0.0000e+00 - val_loss: 0.1980 - val_acc: 0.0000e+00
    Epoch 262/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1637 - acc: 0.0000e+00 - val_loss: 0.2005 - val_acc: 0.0000e+00
    Epoch 263/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1972 - val_acc: 0.0000e+00
    Epoch 264/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.1973 - val_acc: 0.0000e+00
    Epoch 265/300
    115/115 [==============================] - 0s 200us/step - loss: 0.1639 - acc: 0.0000e+00 - val_loss: 0.2007 - val_acc: 0.0000e+00
    Epoch 266/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1975 - val_acc: 0.0000e+00
    Epoch 267/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1633 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 268/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1636 - acc: 0.0000e+00 - val_loss: 0.1968 - val_acc: 0.0000e+00
    Epoch 269/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1981 - val_acc: 0.0000e+00
    Epoch 270/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1984 - val_acc: 0.0000e+00
    Epoch 271/300
    115/115 [==============================] - 0s 204us/step - loss: 0.1631 - acc: 0.0000e+00 - val_loss: 0.1995 - val_acc: 0.0000e+00
    Epoch 272/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1626 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 273/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1638 - acc: 0.0000e+00 - val_loss: 0.1957 - val_acc: 0.0000e+00
    Epoch 274/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1644 - acc: 0.0000e+00 - val_loss: 0.1988 - val_acc: 0.0000e+00
    Epoch 275/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1983 - val_acc: 0.0000e+00
    Epoch 276/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1966 - val_acc: 0.0000e+00
    Epoch 277/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1977 - val_acc: 0.0000e+00
    Epoch 278/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1982 - val_acc: 0.0000e+00
    Epoch 279/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00
    Epoch 280/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 281/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1625 - acc: 0.0000e+00 - val_loss: 0.1970 - val_acc: 0.0000e+00
    Epoch 282/300
    115/115 [==============================] - ETA: 0s - loss: 0.2754 - acc: 0.0000e+0 - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1963 - val_acc: 0.0000e+00
    Epoch 283/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1976 - val_acc: 0.0000e+00
    Epoch 284/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1632 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 285/300
    115/115 [==============================] - 0s 196us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 286/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 287/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1627 - acc: 0.0000e+00 - val_loss: 0.1979 - val_acc: 0.0000e+00
    Epoch 288/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1975 - val_acc: 0.0000e+00
    Epoch 289/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1966 - val_acc: 0.0000e+00
    Epoch 290/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1630 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 291/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1971 - val_acc: 0.0000e+00
    Epoch 292/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1975 - val_acc: 0.0000e+00
    Epoch 293/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1987 - val_acc: 0.0000e+00
    Epoch 294/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1977 - val_acc: 0.0000e+00
    Epoch 295/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1634 - acc: 0.0000e+00 - val_loss: 0.1966 - val_acc: 0.0000e+00
    Epoch 296/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1627 - acc: 0.0000e+00 - val_loss: 0.1983 - val_acc: 0.0000e+00
    Epoch 297/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1975 - val_acc: 0.0000e+00
    Epoch 298/300
    115/115 [==============================] - 0s 187us/step - loss: 0.1628 - acc: 0.0000e+00 - val_loss: 0.1986 - val_acc: 0.0000e+00
    Epoch 299/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1627 - acc: 0.0000e+00 - val_loss: 0.1976 - val_acc: 0.0000e+00
    Epoch 300/300
    115/115 [==============================] - 0s 191us/step - loss: 0.1629 - acc: 0.0000e+00 - val_loss: 0.1989 - val_acc: 0.0000e+00

Let's check the training curve, loss function for our model.

* this is a measure of the inaccuracy

* **square loss** ($L_2$ loss) is the:

\begin{equation}
L_2 = \sum_{\bf{u}_{\alpha} \in AOI} \left(y(\bf{u}_{\alpha}) - \hat{f}(x_1(\bf{u}_{\alpha}),\ldots,x_m(\bf{u}_{\alpha})\right)
\end{equation}

We can see the progress of the model over epochs in reduction of training and testing error.

```python
plt.subplot(2, 1, 1)
plt.plot(hist_1.history["loss"])
plt.plot(hist_1.history["val_loss"])
plt.title("Loss function of Model 1")
plt.ylabel("loss")
plt.xlabel("epoch")
plt.legend(["train", "test"], loc="upper right")
plt.tight_layout()
```

Let's visualize the model in prediction.

```python
AIbins = np.linspace(
    df_subset["AI"].values.min(), df_subset["AI"].values.max(), 30
)  # set the bins for prediction
norm_AIbins = (AIbins - AI_min) / (
    AI_max - AI_min
) * 2 - 1  # use normalized bins

pred_norm_porsity = model_1.predict(
    np.array(norm_AIbins)
)  # predict with our ANN

pred_porosity = (pred_norm_porsity + 1) / 2 * (
    por_max - por_min
) + por_min  # transform it back to original range

plt.figure()
plt.plot(df_subset["AI"].values, df_subset["Porosity"].values, "ko", alpha=0.4)
plt.plot(AIbins, pred_porosity, "r-", linewidth=5)
plt.xlabel("Acoustic Impedance (kg/m2s*10^6)")
plt.ylabel("Porosity (faction)")
plt.show()
```

#### Neural Net-Based Map of Porosity from Seismic Acoustic Impedance

Now let's predict porosity at all locations from the seismic data. First we normalize the seismic data.

* We may have some values below -1.0 and above 1.0 as we are using the transform applied to the acoustic impedance at the wells.

```python
norm_seismic = (seismic - AI_min) / (AI_max - AI_min) * 2 - 1

pred_norm_porosity_map = model_1.predict(
    np.array(norm_seismic.flatten())
)  # predict with our ANN

pred_porosity_map = (pred_norm_porosity_map + 1) / 2 * (
    por_max - por_min
) + por_min  # transform it back to original range
pred_porosity_map = np.reshape(pred_porosity_map, (ny, nx))

plt.subplot(121)
GSLIB.pixelplt_st(
    norm_seismic,
    xmin,
    xmax,
    ymin,
    ymax,
    cell_size,
    -1,
    1,
    "Acoustic Impedance",
    "X(m)",
    "Y(m)",
    "Acoustic Impedance (normalized)",
    cmap,
)

plt.subplot(122)
GSLIB.pixelplt_st(
    pred_porosity_map,
    xmin,
    xmax,
    ymin,
    ymax,
    cell_size,
    por_min,
    por_max,
    "Predicted Porosity",
    "X(m)",
    "Y(m)",
    "Porosity (fraction)",
    cmap,
)
plt.subplots_adjust(
    left=0.0, bottom=0.0, right=2.2, top=1.2, wspace=0.2, hspace=0.2
)
plt.show()
```

#### Visualizing the Neural Net

There are some methods available to interogate the artificial neural net.

* neural net summary

* weights

Here's the summary from our neural net.  It lists by layers the number of nodes and number of parameters.

```python
model_1.summary()
```

    _________________________________________________________________
    Layer (type)                 Output Shape              Param #
    =================================================================
    dense_24 (Dense)             (None, 1)                 2
    _________________________________________________________________
    dense_25 (Dense)             (None, 3)                 6
    _________________________________________________________________
    dense_26 (Dense)             (None, 1)                 4
    =================================================================
    Total params: 12
    Trainable params: 12
    Non-trainable params: 0
    _________________________________________________________________

We can also see the actual trained weights for each node in each layer.

```python
# Weights of Model_1

for layer in model_1.layers:
    g = layer.get_config()
    h = layer.get_weights()
    print(g)
    print(h)
    print("\n")
```

    {'name': 'dense_24', 'trainable': True, 'batch_input_shape': (None, 1), 'dtype': 'float32', 'units': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'scale': 1.0, 'mode': 'fan_avg', 'distribution': 'uniform', 'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}
    [array([[-0.70692515]], dtype=float32), array([0.30242074], dtype=float32)]

    {'name': 'dense_25', 'trainable': True, 'units': 3, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'scale': 1.0, 'mode': 'fan_avg', 'distribution': 'uniform', 'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}
    [array([[ 0.0549653, -0.8047614,  1.0055766]], dtype=float32), array([ 0.26931858,  0.        , -0.00066453], dtype=float32)]

    {'name': 'dense_26', 'trainable': True, 'units': 1, 'activation': 'tanh', 'use_bias': True, 'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'scale': 1.0, 'mode': 'fan_avg', 'distribution': 'uniform', 'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}
    [array([[-1.2730278],
           [-0.4338343],
           [ 1.3375224]], dtype=float32), array([-0.2667548], dtype=float32)]

We can observe the weights and bias terms associate with our neural network.

#### Comments

This was a basic demonstration of artificial neural networks.

The Texas Center for Geostatistics has many other demonstrations on the basics of working with DataFrames, ndarrays, univariate statistics, plotting data, declustering, data transformations, trend modeling and many other workflows available [here](https://github.com/GeostatsGuy/PythonNumericalDemos), along with a package for geostatistics in Python called [GeostatsPy](https://github.com/GeostatsGuy/GeostatsPy).

We hope this was helpful,

*Michael* and *Honggeun*

***

#### More on Michael Pyrcz and the Texas Center for Data Analytics and Geostatistics:

### Michael Pyrcz, Associate Professor, University of Texas at Austin
*Novel Data Analytics, Geostatistics and Machine Learning Subsurface Solutions*

With over 17 years of experience in subsurface consulting, research and development, Michael has returned to academia driven by his passion for teaching and enthusiasm for enhancing engineers' and geoscientists' impact in subsurface resource development.

For more about Michael check out these links:

#### [Twitter](https://twitter.com/geostatsguy) | [GitHub](https://github.com/GeostatsGuy) | [Website](http://michaelpyrcz.com) | [GoogleScholar](https://scholar.google.com/citations?user=QVZ20eQAAAAJ&hl=en&oi=ao) | [Book](https://www.amazon.com/Geostatistical-Reservoir-Modeling-Michael-Pyrcz/dp/0199731446) | [YouTube](https://www.youtube.com/channel/UCLqEr-xV-ceHdXXXrTId5ig)  | [LinkedIn](https://www.linkedin.com/in/michael-pyrcz-61a648a1)

#### Want to Work Together?

I hope this content is helpful to those that want to learn more about subsurface modeling, data analytics and machine learning. Students and working professionals are welcome to participate.

* Want to invite me to visit your company for training, mentoring, project review, workflow design and / or consulting? I'd be happy to drop by and work with you!

* Interested in partnering, supporting my graduate student research or my Subsurface Data Analytics and Machine Learning consortium (co-PIs including Profs. Foster, Torres-Verdin and van Oort)? My research combines data analytics, stochastic modeling and machine learning theory with practice to develop novel methods and workflows to add value. We are solving challenging subsurface problems!

* I can be reached at mpyrcz@austin.utexas.edu.

I'm always happy to discuss,

*Michael*

Michael Pyrcz, Ph.D., P.Eng. Associate Professor The Hildebrand Department of Petroleum and Geosystems Engineering, Bureau of Economic Geology, The Jackson School of Geosciences, The University of Texas at Austin

#### More Resources Available at: [Twitter](https://twitter.com/geostatsguy) | [GitHub](https://github.com/GeostatsGuy) | [Website](http://michaelpyrcz.com) | [GoogleScholar](https://scholar.google.com/citations?user=QVZ20eQAAAAJ&hl=en&oi=ao) | [Book](https://www.amazon.com/Geostatistical-Reservoir-Modeling-Michael-Pyrcz/dp/0199731446) | [YouTube](https://www.youtube.com/channel/UCLqEr-xV-ceHdXXXrTId5ig)  | [LinkedIn](https://www.linkedin.com/in/michael-pyrcz-61a648a1)

```python

```


[Sascha Spors](https://orcid.org/0000-0001-7225-9992),
Professorship Signal Theory and Digital Signal Processing,
[Institute of Communications Engineering (INT)](https://www.int.uni-rostock.de/),
Faculty of Computer Science and Electrical Engineering (IEF),
[University of Rostock, Germany](https://www.uni-rostock.de/en/)

# Tutorial Signals and Systems (Signal- und Systemtheorie)

Summer Semester 2021 (Bachelor Course #24015)

- lecture: https://github.com/spatialaudio/signals-and-systems-lecture
- tutorial: https://github.com/spatialaudio/signals-and-systems-exercises

WIP...
The project is currently under heavy development while adding new material for the summer semester 2021

Feel free to contact lecturer [frank.schultz@uni-rostock.de](https://orcid.org/0000-0002-3010-0294)

## Übung / Exercise 2 Faltung / Convolution : Animation

rect / exp

source code adapted from

https://github.com/spatialaudio/signals-and-systems-lecture/commit/72652fc12b1527698db2e4543d4a16b211526aa2

```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import sympy as sp

plt.rcParams['animation.html'] = 'jshtml'
```

```python
def heaviside(x):
    return np.heaviside(x, .5)

def animate_convolution(x, h, y, td, taud, xlim):

    # add numerical evaluation to symbolic functions
    x_eval = sp.lambdify((tau), x.subs(t, tau), modules=['numpy', {'Heaviside': heaviside}])
    h_eval = sp.lambdify((t, tau), h.subs(t, t - tau), modules=['numpy', {'Heaviside': heaviside}])
    y_eval = sp.lambdify((t), y, modules=['numpy', {'Heaviside': heaviside}])

    # setup plot and line styles
    fig, ax = plt.subplots(2, 1)
    fig.subplots_adjust(hspace=0.5)
    plt.close()  # suppresses empty plot in notebook

    lines = [ax[0].plot([], [], lw=2, label=r'$x_B(t-\tau)$')[0]]
    lines.append(ax[0].plot([], [], lw=2, label=r'$x_A(\tau)$')[0])
    lines.append(ax[1].plot([], [], 'g-', lw=2, label=r'$y(t) = x_A(t) * x_B(t)$')[0])
    lines.append(ax[1].plot([], [], 'ro', lw=2)[0])

    ax[0].set_xticks(np.arange(-2,6,1/2))
    ax[0].set_xlim(xlim)
    ax[0].set_ylim((-0.1, 2.1))
    ax[0].set_xlabel(r'$\tau$')
    ax[0].legend(loc='upper right')
    ax[0].grid(True)

    ax[1].set_xticks(np.arange(-2,6,1/2))
    ax[1].set_xlim(xlim)
    ax[1].set_ylim((-0.01, 0.4))
    ax[1].set_xlabel(r'$t$')
    ax[1].legend(loc='lower left')
    ax[1].grid(True)

    if False:  # check manual calc
        t1 = np.linspace(1,3/2,100)
        x1 = -2*t1**2 + 6*t1 - 4
        ax[1].plot(t1,x1, 'C3')

        t2 = np.linspace(3/2,3,100)
        x2 = t2*0+1/2
        ax[1].plot(t2,x2, 'C3')

        t3 = np.linspace(3,7/2,100)
        x3 = +2*t3**2 -14*t3 +49/2
        ax[1].plot(t3,x3, 'C3')

    def animate(ti):
        ax[0].collections.clear()
        ax[0].fill_between(taud, 0, h_eval(ti, taud)*x_eval(taud), facecolor='gray', alpha=0.3)

        lines[0].set_data(taud, h_eval(ti, taud))
        lines[1].set_data(taud, x_eval(taud))

        lines[2].set_data(taud, y_eval(taud))
        lines[3].set_data(ti, y_eval(ti))

        return lines

    return animation.FuncAnimation(fig, animate, td, interval=50, blit=True)
```

```python
class rect(sp.Function):

    @classmethod
    def eval(cls, arg):
        return sp.Heaviside(arg + sp.S.Half) - sp.Heaviside(arg - sp.S.Half)

t, tau = sp.symbols('t tau', real=True)
```

## UE 2.7

For the given signals

\begin{equation}
h(t) =
\begin{cases}
\mathrm{e}^{-(t-1) \cdot 6} \quad \mathrm{for} \quad 1 \leq t \leq \frac{3}{2}\\
0 \quad \mathrm{else}
\end{cases}
\end{equation}

\begin{equation}
h(t) = \mathrm{e}^{-(t-1) \cdot 6} \cdot \mathrm{rect}\left(\left[t-\frac{5}{4}\right] \cdot 2\right)
\end{equation}

and
\begin{equation}
x(t)=
\begin{cases}
  2 \quad \mathrm{for} \quad 0 \leq t \leq 2\\
  0 \quad \mathrm{else}
\end{cases}
\end{equation}
\begin{equation}
x(t) = 2\cdot\mathrm{rect}\left(\left[t-1\right] \cdot \frac{1}{2}\right)
\end{equation}
the convolution
\begin{equation}
y(t) = h(t) \ast x(t) = x(t) \ast h(t)
\end{equation}
is to be calculated analytically. The signals $h(t)$, $x(t)$ and $y(t)$ are to be visualized.

```python
time_constant_RC = (1/2)/3
area_under_exp = 1/3 - 1 / (3 * np.exp(1)**3)

x = 2 * rect((t-1)*1/2)
h = (sp.exp(-(t-1)/time_constant_RC)) * rect((t-5/4)*2)  # note: cut exp function
```

```python
xA = x
xB = h
y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),
                  (tau, 0, t))  # for causal signals

anim = animate_convolution(
    x=xA,
    h=xB,
    y=y,
    td=np.arange(-2, 10, .1),
    taud=np.arange(-10, 10, 0.01),
    xlim=(-2, 5))
anim

```

$$y(t) = \int x_A(\tau) \cdot x_B(-\tau + t) \mathrm{d}\tau$$

$$y(t) = \int x(\tau) \cdot h(-\tau + t) \mathrm{d}\tau$$

```python
xA = h
xB = x
y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),
                  (tau, 0, t))  # for causal signals

anim = animate_convolution(
    x=xA,
    h=xB,
    y=y,
    td=np.arange(-2, 10, .1),
    taud=np.arange(-10, 10, 0.01),
    xlim=(-2, 5))
anim
```

$$y(t) = \int x_A(\tau) \cdot x_B(-\tau + t) \mathrm{d}\tau$$

$$y(t) = \int h(\tau) \cdot x(-\tau + t) \mathrm{d}\tau$$

## Copyright

This tutorial is provided as Open Educational Resource (OER), to be found at
https://github.com/spatialaudio/signals-and-systems-exercises
accompanying the OER lecture
https://github.com/spatialaudio/signals-and-systems-lecture.
Both are licensed under a) the Creative Commons Attribution 4.0 International
License for text and graphics and b) the MIT License for source code.
Please attribute material from the tutorial as *Frank Schultz,
Continuous- and Discrete-Time Signals and Systems - A Tutorial Featuring
Computational Examples, University of Rostock* with
``main file, github URL, commit number and/or version tag, year``.


# Applied Stochastic Processes HW_07

**11510691 程远星$\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\plim}{plim}
\newcommand{\using}[1]{\stackrel{\mathrm{#1}}{=}}
\newcommand{\ffrac}{\displaystyle \frac}
\newcommand{\asim}{\overset{\text{a}}{\sim}}
\newcommand{\space}{\text{ }}
\newcommand{\bspace}{\;\;\;\;}
\newcommand{\QQQ}{\boxed{?\:}}
\newcommand{\void}{\left.\right.}
\newcommand{\Tran}[1]{{#1}^{\mathrm{T}}}
\newcommand{\d}[1]{\displaystyle{#1}}
\newcommand{\CB}[1]{\left\{ #1 \right\}}
\newcommand{\SB}[1]{\left[ #1 \right]}
\newcommand{\P}[1]{\left( #1 \right)}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\norm}[1]{\left\| #1 \right\|}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\Exp}{\mathrm{E}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\EE}{\mathbb{E}}
\newcommand{\II}{\mathbb{I}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\AcA}{\mathcal{A}}
\newcommand{\FcF}{\mathcal{F}}
\newcommand{\AsA}{\mathscr{A}}
\newcommand{\FsF}{\mathscr{F}}
\newcommand{\Var}[2][\,\!]{\mathrm{Var}_{#1}\left[#2\right]}
\newcommand{\Avar}[2][\,\!]{\mathrm{Avar}_{#1}\left[#2\right]}
\newcommand{\Cov}[2][\,\!]{\mathrm{Cov}_{#1}\left(#2\right)}
\newcommand{\Corr}[2][\,\!]{\mathrm{Corr}_{#1}\left(#2\right)}
\newcommand{\I}[1]{\mathrm{I}\left( #1 \right)}
\newcommand{\N}[1]{\mathcal{N} \left( #1 \right)}
\newcommand{\ow}{\text{otherwise}}
\void^\dagger$**

## Question 1

$\P{1}$

$\bspace$The answer is obviously since each transition is independet and we have:

$$f_{00}^{\P{n}} = \begin{cases}
0,&\text{if } n=0\\
P_{00} =1-a,&\text{if } n=1\\
P_{01}\cdot P_{11}^{n-2} \cdot P_{10} = ab\P{1-b}^{n-2},&\text{if } n\geq2
\end{cases}$$

$\P{2}$

$$f_{00} = \sum_{n=0}^{\infty}f_{00}^{\P{n}} = \P{1-a} + \sum_{n=2}^{\infty}ab\P{1-b}^{n-2}= 1$$

$\bspace$And the series have the sum is because $0<b<1$.

$\P{3}$

$\bspace$The limiting distribution exists because the Markov Chain here is irreducible, of course, and also aperiodic, from the fact that $P_{00}^{\P{1}} = \P{1-a}>0$.

$\bspace$Let the limiting distribution be $\pi_0$ and $\pi_1$, and since they're equal to the long-run proportions, respectively we have the equations:

$$\begin{cases}
\P{1-a}\pi_0+ b\cdot\pi_1 = \pi_0\\
a\cdot\pi_0 + \P{1-b}\pi_1 = \pi_1\\
\pi_0+\pi_1 = 1
\end{cases} \Longrightarrow \begin{cases}
\pi_0 = \ffrac{b} {a+b}\\
\pi_1 = \ffrac{a} {a+b}
\end{cases}$$

## Question 2

$\P{1}$

$$\mathbf{P}^2 = \begin{Vmatrix}
\ffrac{1} {2} & \ffrac{3} {8} & \ffrac{1} {8}\\
\ffrac{3} {8} & \ffrac{7} {16} & \ffrac{3} {16}\\
\ffrac{1} {4} & \ffrac{3} {8} & \ffrac{3} {8}
\end{Vmatrix}$$

$\bspace$So that we have $P\CB{X_2=S\mid X_0=C} = 3/8$; $P\CB{X_2=C\mid X_0=C} = 7/16$; $P\CB{X_2=R\mid X_0=C} = 3/16$.

$\P{2}$

$\bspace$**irreducible**: $S \to C \to R \to C \to S$
$\bspace$**positive recurrent**: this Markov Chain is also finite
$\bspace$**aperiodic**: $P_{SS}^{\P{1}}, P_{CC}^{\P{1}}, P_{RR}^{\P{1}}>0$

$\bspace$And thus, **erogodic**.

$\P{3}$

$\bspace$Since this Markov Chain is erogodic, we have the equations for its limiting probabilities $\P{\pi_1,\pi_2,\pi_3}$:

$$\begin{cases}
\pi_1 = 0.5\pi_1 + 0.5\pi_2 \\
\pi_2 = 0.5\pi_1 + 0.25\pi_2 + 0.5\pi_3\\
\pi_3 = 0.25\pi_2 + 0.5\pi_3\\
\pi_1+\pi_2+\pi_3 = 1
\end{cases} \Longrightarrow \begin{cases}
\pi_1 = 0.4\\
\pi_2 = 0.4\\
\pi_3 = 0.2
\end{cases}$$

$\bspace$Thus in the long run, the percentages of the days are sunny, cloudy and rainy are $40\%$, $40\%$ and $20\%$ respectively.

## Question 3

$\bspace$Let the one-step transition matrix be $\mathbf{P}$. First, we prove that the limit probabilities exist. Irreducible, given in the context; finite, also given and thus positive recurrent; aperiodic, well this property can't be proved and actually there's a conterexample:

$$\begin{Vmatrix}
0 & 1 \\
1 & 0
\end{Vmatrix}$$

$\bspace$So let's just assume it to be true. Then assume the limiting probabilities be $\vec{\pi} = \Tran{\CB{\pi_1,\pi_2,\cdots,\pi_M}}$ for this Markov Chain with totally $M$ states. We have the equation:

$$\begin{cases}
\Tran{\mathbf{P}}\vec{\pi} = \vec{\pi}\\
\Tran{\mathbf{1}}\vec{\pi} = 1
\end{cases}$$

$\bspace$However the extra condition is equivalent to $\Tran{\mathbf{P}}{\mathbf{1}} = \mathbf{1}$. Comparaing this with the first equation we have $\vec{\pi} = k \cdot \mathbf{1}$ and further by the second one we have

$$\vec{\pi} = \ffrac{1} {M} \mathbf{1}$$

## Question 4

$\bspace$Two classes: $\CB{1,2,3}$ and $\CB{4}$, transient and recurrent respectively. First we have

$$\mathbf P_T = \begin{bmatrix}
0.4 & 0.2 & 0.1\\
0.1 & 0.5 & 0.2\\
0.3 & 0.4 & 0.2
\end{bmatrix}\Rightarrow \mathbf S = \begin{bmatrix}
2.2069 & 1.3793 & 0.6207\\
0.9655 & 3.1034 & 0.8966\\
1.3103 & 2.0690 & 1.9310
\end{bmatrix}$$

$\bspace$And with this we have $s_{1,3} \approx 0.6027$, $s_{2,3} \approx 0.8966$ and $s_{3,3} \approx 1.9310$. Then

$$f_{1,3} = \ffrac{s_{1,3} - \delta_{1,3}} {s_{3,3}} = \ffrac{0.6207-0} {1.9310}=0.3214\\
f_{2,3} = \ffrac{s_{2,3} - 0} {s_{3,3}} = \ffrac{0.8966} {1.9310}=0.4643\\
f_{3,3} = \ffrac{s_{3,3} - 1} {s_{3,3}} = \ffrac{1.9310-1} {1.9310}=0.4821$$

## Question 5

$\P{1}$

$$P\P{i} = \alpha_i\cdot P\P{i+1} + \P{1-\alpha_i}\cdot P\P{i-1}$$

$\P{2}$

$$P\P{i+1}-P\P{i} = \ffrac{1-\alpha_i} {\alpha_i}\P{P\P{i}-P\P{i-1}}\Rightarrow P\P{i} - P\P{i-1} = P\P{1} \cdot \prod_{j=1}^{i-1} \ffrac{1-\alpha_j} {\alpha_j} \\
\Rightarrow P\P{i} = P\P{1}\SB{1+\sum_{k=2}^{i} \P{\prod_{j=1}^{k-1}\ffrac{1-\alpha_j} {\alpha_j}}}$$

$\P{3}$

$\bspace$The required probability is the same with the probability that the number of balls in urn $2$ reaches $N$ before $0$. And for urn $2$, the winning probability is $\alpha_i=\ffrac{i} {N}$ where it gets one more ball. Then

$$\begin{align}
P\P{i} &= P\P{1}\SB{1+\sum_{k=2}^{i} \P{\prod_{j=1}^{k-1}\ffrac{1-\ffrac{j} {N}} {\ffrac{j} {N}}}}\\
&= P\P{1}\SB{1+\sum_{k=2}^{i} \ffrac{\P{N-1}!} {\P{N-k}!\P{k-1}!}}\\
&= P\P{1}\SB{\sum_{k=1}^{i} \binom{N-1} {k-1}}
\end{align}$$

$\bspace$And consider when $i=N$ then $P\P{N} = p\P{1}\cdot 2^{N-1} = 1$, then we have

$$P\P{i} = 2^{1-N}\cdot\SB{\sum_{k=1}^{i} \binom{N-1} {k-1}}$$

***

Probability and Statistics/Applied Random Process/HW/HW_07.ipynb