Artificial Intelligence Nanodegree

Computer Vision Capstone

Project: Facial Keypoint Detection


Welcome to the final Computer Vision project in the Artificial Intelligence Nanodegree program!

In this project, you’ll combine your knowledge of computer vision techniques and deep learning to build and end-to-end facial keypoint recognition system! Facial keypoints include points around the eyes, nose, and mouth on any face and are used in many applications, from facial tracking to emotion recognition.

There are three main parts to this project:

Part 1 : Investigating OpenCV, pre-processing, and face detection

Part 2 : Training a Convolutional Neural Network (CNN) to detect facial keypoints

Part 3 : Putting parts 1 and 2 together to identify facial keypoints on any image!


*Here's what you need to know to complete the project:

  1. In this notebook, some template code has already been provided for you, and you will need to implement additional functionality to successfully complete this project. You will not need to modify the included code beyond what is requested.

    a. Sections that begin with '(IMPLEMENTATION)' in the header indicate that the following block of code will require additional functionality which you must provide. Instructions will be provided for each section, and the specifics of the implementation are marked in the code block with a 'TODO' statement. Please be sure to read the instructions carefully!

  1. In addition to implementing code, there will be questions that you must answer which relate to the project and your implementation.

    a. Each section where you will answer a question is preceded by a 'Question X' header.

    b. Carefully read each question and provide thorough answers in the following text boxes that begin with 'Answer:'.

Note: Code and Markdown cells can be executed using the Shift + Enter keyboard shortcut. Markdown cells can be edited by double-clicking the cell to enter edit mode.

The rubric contains optional suggestions for enhancing the project beyond the minimum requirements. If you decide to pursue the "(Optional)" sections, you should include the code in this IPython notebook.

Your project submission will be evaluated based on your answers to each of the questions and the code implementations you provide.

Steps to Complete the Project

Each part of the notebook is further broken down into separate steps. Feel free to use the links below to navigate the notebook.

In this project you will get to explore a few of the many computer vision algorithms built into the OpenCV library. This expansive computer vision library is now almost 20 years old and still growing!

The project itself is broken down into three large parts, then even further into separate steps. Make sure to read through each step, and complete any sections that begin with '(IMPLEMENTATION)' in the header; these implementation sections may contain multiple TODOs that will be marked in code. For convenience, we provide links to each of these steps below.

Part 1 : Investigating OpenCV, pre-processing, and face detection

  • Step 0: Detect Faces Using a Haar Cascade Classifier
  • Step 1: Add Eye Detection
  • Step 2: De-noise an Image for Better Face Detection
  • Step 3: Blur an Image and Perform Edge Detection
  • Step 4: Automatically Hide the Identity of an Individual

Part 2 : Training a Convolutional Neural Network (CNN) to detect facial keypoints

  • Step 5: Create a CNN to Recognize Facial Keypoints
  • Step 6: Compile and Train the Model
  • Step 7: Visualize the Loss and Answer Questions

Part 3 : Putting parts 1 and 2 together to identify facial keypoints on any image!

  • Step 8: Build a Robust Facial Keypoints Detector (Complete the CV Pipeline)

Step 0: Detect Faces Using a Haar Cascade Classifier

Have you ever wondered how Facebook automatically tags images with your friends' faces? Or how high-end cameras automatically find and focus on a certain person's face? Applications like these depend heavily on the machine learning task known as face detection - which is the task of automatically finding faces in images containing people.

At its root face detection is a classification problem - that is a problem of distinguishing between distinct classes of things. With face detection these distinct classes are 1) images of human faces and 2) everything else.

We use OpenCV's implementation of Haar feature-based cascade classifiers to detect human faces in images. OpenCV provides many pre-trained face detectors, stored as XML files on github. We have downloaded one of these detectors and stored it in the detector_architectures directory.

Import Resources

In the next python cell, we load in the required libraries for this section of the project.


In [1]:
# Import required libraries for this section

%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
import math
import cv2                     # OpenCV library for computer vision
from PIL import Image
import time

Next, we load in and display a test image for performing face detection.

Note: by default OpenCV assumes the ordering of our image's color channels are Blue, then Green, then Red. This is slightly out of order with most image types we'll use in these experiments, whose color channels are ordered Red, then Green, then Blue. In order to switch the Blue and Red channels of our test image around we will use OpenCV's cvtColor function, which you can read more about by checking out some of its documentation located here. This is a general utility function that can do other transformations too like converting a color image to grayscale, and transforming a standard color image to HSV color space.


In [2]:
# Load in color image for face detection
image = cv2.imread('images/test_image_1.jpg')

# Convert the image to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Plot our image using subplots to specify a size and title
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Original Image')
ax1.imshow(image)


Out[2]:
<matplotlib.image.AxesImage at 0x1118c0b70>

There are a lot of people - and faces - in this picture. 13 faces to be exact! In the next code cell, we demonstrate how to use a Haar Cascade classifier to detect all the faces in this test image.

This face detector uses information about patterns of intensity in an image to reliably detect faces under varying light conditions. So, to use this face detector, we'll first convert the image from color to grayscale.

Then, we load in the fully trained architecture of the face detector -- found in the file haarcascade_frontalface_default.xml - and use it on our image to find faces!

To learn more about the parameters of the detector see this post.


In [3]:
# Convert the RGB  image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# Detect the faces in image
faces = face_cascade.detectMultiScale(gray, 4, 6)

# Print the number of faces detected in the image
print('Number of faces detected:', len(faces))

# Make a copy of the orginal image to draw face detections on
image_with_detections = np.copy(image)

# Get the bounding box for each detected face
for (x,y,w,h) in faces:
    # Add a red bounding box to the detections image
    cv2.rectangle(image_with_detections, (x,y), (x+w,y+h), (255,0,0), 3)
    

# Display the image with the detections
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Image with Face Detections')
ax1.imshow(image_with_detections)


Number of faces detected: 13
Out[3]:
<matplotlib.image.AxesImage at 0x103e48ef0>

In the above code, faces is a numpy array of detected faces, where each row corresponds to a detected face. Each detected face is a 1D array with four entries that specifies the bounding box of the detected face. The first two entries in the array (extracted in the above code as x and y) specify the horizontal and vertical positions of the top left corner of the bounding box. The last two entries in the array (extracted here as w and h) specify the width and height of the box.


Step 1: Add Eye Detections

There are other pre-trained detectors available that use a Haar Cascade Classifier - including full human body detectors, license plate detectors, and more. A full list of the pre-trained architectures can be found here.

To test your eye detector, we'll first read in a new test image with just a single face.


In [4]:
# Load in color image for face detection
image = cv2.imread('images/james.jpg')

# Convert the image to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Plot the RGB image
fig = plt.figure(figsize = (6,6))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Original Image')
ax1.imshow(image)


Out[4]:
<matplotlib.image.AxesImage at 0x104fd0470>

Notice that even though the image is a black and white image, we have read it in as a color image and so it will still need to be converted to grayscale in order to perform the most accurate face detection.

So, the next steps will be to convert this image to grayscale, then load OpenCV's face detector and run it with parameters that detect this face accurately.


In [5]:
# Convert the RGB  image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# Detect the faces in image
faces = face_cascade.detectMultiScale(gray, 1.25, 6)

# Print the number of faces detected in the image
print('Number of faces detected:', len(faces))

# Make a copy of the orginal image to draw face detections on
image_with_detections = np.copy(image)

# Get the bounding box for each detected face
for (x,y,w,h) in faces:
    # Add a red bounding box to the detections image
    cv2.rectangle(image_with_detections, (x,y), (x+w,y+h), (255,0,0), 3)
    

# Display the image with the detections
fig = plt.figure(figsize = (6,6))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Image with Face Detection')
ax1.imshow(image_with_detections)


Number of faces detected: 1
Out[5]:
<matplotlib.image.AxesImage at 0x113ccdf60>

(IMPLEMENTATION) Add an eye detector to the current face detection setup.

A Haar-cascade eye detector can be included in the same way that the face detector was and, in this first task, it will be your job to do just this.

To set up an eye detector, use the stored parameters of the eye cascade detector, called haarcascade_eye.xml, located in the detector_architectures subdirectory. In the next code cell, create your eye detector and store its detections.

A few notes before you get started:

First, make sure to give your loaded eye detector the variable name

eye_cascade

and give the list of eye regions you detect the variable name

eyes

Second, since we've already run the face detector over this image, you should only search for eyes within the rectangular face regions detected in faces. This will minimize false detections.

Lastly, once you've run your eye detector over the facial detection region, you should display the RGB image with both the face detection boxes (in red) and your eye detections (in green) to verify that everything works as expected.


In [6]:
# Make a copy of the original image to plot rectangle detections
image_with_detections = np.copy(image)   

# Loop over the detections and draw their corresponding face detection boxes
for (x,y,w,h) in faces:
    cv2.rectangle(image_with_detections, (x,y), (x+w,y+h),(255,0,0), 3)  

# Do not change the code above this comment!

    
## TODO: Add eye detection, using haarcascade_eye.xml, to the current face detector algorithm
eye_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_eye.xml')
eyes = eye_cascade.detectMultiScale(gray, 1.20, 6)

## TODO: Loop over the eye detections and draw their corresponding boxes in green on image_with_detections
for (x,y,w,h) in eyes:
    for (fx, fy, fw, fh) in faces:
        # check coordinates are within face bounds
        if x >= fx and x <= fx+fw and y >= fy and y <= fy+fh:
            cv2.rectangle(image_with_detections, (x,y), (x+w,y+h),(0,255,0), 3)

# Plot the image with both faces and eyes detected
fig = plt.figure(figsize = (6,6))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Image with Face and Eye Detection')
ax1.imshow(image_with_detections)


Out[6]:
<matplotlib.image.AxesImage at 0x10d99c0f0>

(Optional) Add face and eye detection to your laptop camera

It's time to kick it up a notch, and add face and eye detection to your laptop's camera! Afterwards, you'll be able to show off your creation like in the gif shown below - made with a completed version of the code!

Notice that not all of the detections here are perfect - and your result need not be perfect either. You should spend a small amount of time tuning the parameters of your detectors to get reasonable results, but don't hold out for perfection. If we wanted perfection we'd need to spend a ton of time tuning the parameters of each detector, cleaning up the input image frames, etc. You can think of this as more of a rapid prototype.

The next cell contains code for a wrapper function called laptop_camera_face_eye_detector that, when called, will activate your laptop's camera. You will place the relevant face and eye detection code in this wrapper function to implement face/eye detection and mark those detections on each image frame that your camera captures.

Before adding anything to the function, you can run it to get an idea of how it works - a small window should pop up showing you the live feed from your camera; you can press any key to close this window.

Note: Mac users may find that activating this function kills the kernel of their notebook every once in a while. If this happens to you, just restart your notebook's kernel, activate cell(s) containing any crucial import statements, and you'll be good to go!


In [7]:
### Add face and eye detection to this laptop camera function 
# Make sure to draw out all faces/eyes found in each frame on the shown video feed

import cv2
import time 

# wrapper function for face/eye detection with your laptop camera
def laptop_camera_go():
    # Create instance of video capturer
    cv2.namedWindow("face detection activated")
    vc = cv2.VideoCapture(0)

    # Try to get the first frame
    if vc.isOpened(): 
        rval, frame = vc.read()
    else:
        rval = False
    
    # Keep the video stream open
    while rval:
        # Plot the image from camera with all the face and eye detections marked
        cv2.imshow("face detection activated", frame)
        
        # Exit functionality - press any key to exit laptop video
        key = cv2.waitKey(20)
        if key > 0: # Exit by pressing any key
            # Destroy windows 
            cv2.destroyAllWindows()
            
            # Make sure window closes on OSx
            for i in range (1,5):
                cv2.waitKey(1)
            return
        
        # Read next frame
        time.sleep(0.05)             # control framerate for computation - default 20 frames per sec
        rval, frame = vc.read()

In [8]:
# Call the laptop camera face/eye detector function above
#laptop_camera_go()

Step 2: De-noise an Image for Better Face Detection

Image quality is an important aspect of any computer vision task. Typically, when creating a set of images to train a deep learning network, significant care is taken to ensure that training images are free of visual noise or artifacts that hinder object detection. While computer vision algorithms - like a face detector - are typically trained on 'nice' data such as this, new test data doesn't always look so nice!

When applying a trained computer vision algorithm to a new piece of test data one often cleans it up first before feeding it in. This sort of cleaning - referred to as pre-processing - can include a number of cleaning phases like blurring, de-noising, color transformations, etc., and many of these tasks can be accomplished using OpenCV.

In this short subsection we explore OpenCV's noise-removal functionality to see how we can clean up a noisy image, which we then feed into our trained face detector.

Create a noisy image to work with

In the next cell, we create an artificial noisy version of the previous multi-face image. This is a little exaggerated - we don't typically get images that are this noisy - but image noise, or 'grainy-ness' in a digitial image - is a fairly common phenomenon.


In [9]:
# Load in the multi-face test image again
image = cv2.imread('images/test_image_1.jpg')

# Convert the image copy to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Make an array copy of this image
image_with_noise = np.asarray(image)

# Create noise - here we add noise sampled randomly from a Gaussian distribution: a common model for noise
noise_level = 40
noise = np.random.randn(image.shape[0],image.shape[1],image.shape[2])*noise_level

# Add this noise to the array image copy
image_with_noise = image_with_noise + noise

# Convert back to uint8 format
image_with_noise = np.asarray([np.uint8(np.clip(i,0,255)) for i in image_with_noise])

# Plot our noisy image!
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Noisy Image')
ax1.imshow(image_with_noise)


Out[9]:
<matplotlib.image.AxesImage at 0x10d727588>

In the context of face detection, the problem with an image like this is that - due to noise - we may miss some faces or get false detections.

In the next cell we apply the same trained OpenCV detector with the same settings as before, to see what sort of detections we get.


In [10]:
# Convert the RGB  image to grayscale
gray_noise = cv2.cvtColor(image_with_noise, cv2.COLOR_RGB2GRAY)

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# Detect the faces in image
faces = face_cascade.detectMultiScale(gray_noise, 4, 6)

# Print the number of faces detected in the image
print('Number of faces detected:', len(faces))

# Make a copy of the orginal image to draw face detections on
image_with_detections = np.copy(image_with_noise)

# Get the bounding box for each detected face
for (x,y,w,h) in faces:
    # Add a red bounding box to the detections image
    cv2.rectangle(image_with_detections, (x,y), (x+w,y+h), (255,0,0), 3)
    

# Display the image with the detections
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Noisy Image with Face Detections')
ax1.imshow(image_with_detections)


Number of faces detected: 11
Out[10]:
<matplotlib.image.AxesImage at 0x10daa51d0>

With this added noise we now miss one of the faces!

(IMPLEMENTATION) De-noise this image for better face detection

Time to get your hands dirty: using OpenCV's built in color image de-noising functionality called fastNlMeansDenoisingColored - de-noise this image enough so that all the faces in the image are properly detected. Once you have cleaned the image in the next cell, use the cell that follows to run our trained face detector over the cleaned image to check out its detections.

You can find its official documentation here and a useful example here.

Note: you can keep all parameters except photo_render fixed as shown in the second link above. Play around with the value of this parameter - see how it affects the resulting cleaned image.


In [11]:
## TODO: Use OpenCV's built in color image de-noising function to clean up our noisy image!

denoised_image = cv2.fastNlMeansDenoisingColored(image_with_noise, None, 20, 15, 21, 7)

fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Denoised Image')
ax1.imshow(denoised_image)


Out[11]:
<matplotlib.image.AxesImage at 0x10da00908>

In [12]:
## TODO: Run the face detector on the de-noised image to improve your detections and display the result

# Convert the RGB  image to grayscale
gray_noise = cv2.cvtColor(denoised_image, cv2.COLOR_RGB2GRAY)

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# Detect the faces in image
faces = face_cascade.detectMultiScale(gray_noise, 4, 6)

# Print the number of faces detected in the image
print('Number of faces detected:', len(faces))

# Make a copy of the orginal image to draw face detections on
denoised_image_with_detections = np.copy(denoised_image)

# Get the bounding box for each detected face
for (x,y,w,h) in faces:
    # Add a red bounding box to the detections image
    cv2.rectangle(denoised_image_with_detections, (x,y), (x+w,y+h), (255,0,0), 3)
    

# Display the image with the detections
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Noisy Image with Face Detections')
ax1.imshow(denoised_image_with_detections)


Number of faces detected: 13
Out[12]:
<matplotlib.image.AxesImage at 0x111f094e0>

Step 3: Blur an Image and Perform Edge Detection

Now that we have developed a simple pipeline for detecting faces using OpenCV - let's start playing around with a few fun things we can do with all those detected faces!

Importance of Blur in Edge Detection

Edge detection is a concept that pops up almost everywhere in computer vision applications, as edge-based features (as well as features built on top of edges) are often some of the best features for e.g., object detection and recognition problems.

Edge detection is a dimension reduction technique - by keeping only the edges of an image we get to throw away a lot of non-discriminating information. And typically the most useful kind of edge-detection is one that preserves only the important, global structures (ignoring local structures that aren't very discriminative). So removing local structures / retaining global structures is a crucial pre-processing step to performing edge detection in an image, and blurring can do just that.

Below is an animated gif showing the result of an edge-detected cat taken from Wikipedia, where the image is gradually blurred more and more prior to edge detection. When the animation begins you can't quite make out what it's a picture of, but as the animation evolves and local structures are removed via blurring the cat becomes visible in the edge-detected image.

Edge detection is a convolution performed on the image itself, and you can read about Canny edge detection on this OpenCV documentation page.

Canny edge detection

In the cell below we load in a test image, then apply Canny edge detection on it. The original image is shown on the left panel of the figure, while the edge-detected version of the image is shown on the right. Notice how the result looks very busy - there are too many little details preserved in the image before it is sent to the edge detector. When applied in computer vision applications, edge detection should preserve global structure; doing away with local structures that don't help describe what objects are in the image.


In [16]:
# Load in the image
image = cv2.imread('images/fawzia.jpg')

# Convert to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Convert to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)  

# Perform Canny edge detection
edges = cv2.Canny(gray, 100, 200)

# Dilate the image to amplify edges
edges = cv2.dilate(edges, None)

# Plot the RGB and edge-detected image
fig = plt.figure(figsize = (15,15))
ax1 = fig.add_subplot(121)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Original Image')
ax1.imshow(image)

ax2 = fig.add_subplot(122)
ax2.set_xticks([])
ax2.set_yticks([])

ax2.set_title('Canny Edges')
ax2.imshow(edges, cmap='gray')


Out[16]:
<matplotlib.image.AxesImage at 0x113bbda20>

Without first blurring the image, and removing small, local structures, a lot of irrelevant edge content gets picked up and amplified by the detector (as shown in the right panel above).

(IMPLEMENTATION) Blur the image then perform edge detection

In the next cell, you will repeat this experiment - blurring the image first to remove these local structures, so that only the important boudnary details remain in the edge-detected image.

Blur the image by using OpenCV's filter2d functionality - which is discussed in this documentation page - and use an averaging kernel of width equal to 4.


In [44]:
### TODO: Blur the test imageusing OpenCV's filter2d functionality, 
# Use an averaging kernel, and a kernel width equal to 4

# Load in the image
image = cv2.imread('images/fawzia.jpg')

# Convert to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

width = 4
kernel = np.ones((width, width),np.float32)/16
dst = cv2.filter2D(image, -1, kernel)

## TODO: Then perform Canny edge detection and display the output

# Convert to grayscale
gray = cv2.cvtColor(dst, cv2.COLOR_RGB2GRAY)  

# Perform Canny edge detection
edges = cv2.Canny(gray, 50, 200)

# Dilate the image to amplify edges
edges = cv2.dilate(edges, None)

# Plot the RGB and edge-detected image
fig = plt.figure(figsize = (15,15))
ax1 = fig.add_subplot(121)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Original Image')
ax1.imshow(image)

ax2 = fig.add_subplot(122)
ax2.set_xticks([])
ax2.set_yticks([])

ax2.set_title('Canny Edges')
ax2.imshow(edges, cmap='gray')


Out[44]:
<matplotlib.image.AxesImage at 0x124e34358>

Step 4: Automatically Hide the Identity of an Individual

If you film something like a documentary or reality TV, you must get permission from every individual shown on film before you can show their face, otherwise you need to blur it out - by blurring the face a lot (so much so that even the global structures are obscured)! This is also true for projects like Google's StreetView maps - an enormous collection of mapping images taken from a fleet of Google vehicles. Because it would be impossible for Google to get the permission of every single person accidentally captured in one of these images they blur out everyone's faces, the detected images must automatically blur the identity of detected people. Here's a few examples of folks caught in the camera of a Google street view vehicle.

Read in an image to perform identity detection

Let's try this out for ourselves. Use the face detection pipeline built above and what you know about using the filter2D to blur and image, and use these in tandem to hide the identity of the person in the following image - loaded in and printed in the next cell.


In [15]:
# Load in the image
image = cv2.imread('images/gus.jpg')

# Convert the image to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Display the image
fig = plt.figure(figsize = (6,6))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.set_title('Original Image')
ax1.imshow(image)


Out[15]:
<matplotlib.image.AxesImage at 0x7fd3ec3cfd30>

(IMPLEMENTATION) Use blurring to hide the identity of an individual in an image

The idea here is to 1) automatically detect the face in this image, and then 2) blur it out! Make sure to adjust the parameters of the averaging blur filter to completely obscure this person's identity.


In [16]:
## TODO: Implement face detection
def blur_face(image, denoiser):
    denoised_image = denoiser(image)

    gray = cv2.cvtColor(denoised_image, cv2.COLOR_RGB2GRAY)

    # Extract the pre-trained face detector from an xml file
    face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

    # Detect the faces in image
    faces = face_cascade.detectMultiScale(gray, 1.1, 10)

    # Make a copy of the orginal image to blur
    final_image = np.copy(image)

    ## TODO: Blur the bounding box around each detected face using an averaging filter and display the result
    width = 60
    kernel = np.ones((width, width),np.float32) / 3600
    image_with_blur = cv2.filter2D(image, -1, kernel)

    for (x,y,w,h) in faces:
        padding = 30
        x_start = max(x - padding, 0)
        y_start = max(y - padding, 0)
        x_end = min(x + w + padding, image.shape[1])
        y_end = min(y + h + padding, image.shape[0])
        final_image[y_start:y_end, x_start:x_end] = cv2.filter2D(image_with_blur[y_start:y_end, x_start:x_end], -1, kernel)


    return final_image

def denoiser(image):
    return cv2.fastNlMeansDenoisingColored(image, None, 10, 10, 21, 7)

final_image = blur_face(image, denoiser)
# Display the image with the detections
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Image with Blurred Face')
ax1.imshow(final_image)


Out[16]:
<matplotlib.image.AxesImage at 0x7fd3ec345da0>

(Optional) Build identity protection into your laptop camera

In this optional task you can add identity protection to your laptop camera, using the previously completed code where you added face detection to your laptop camera - and the task above. You should be able to get reasonable results with little parameter tuning - like the one shown in the gif below.

As with the previous video task, to make this perfect would require significant effort - so don't strive for perfection here, strive for reasonable quality.

The next cell contains code a wrapper function called laptop_camera_identity_hider that - when called - will activate your laptop's camera. You need to place the relevant face detection and blurring code developed above in this function in order to blur faces entering your laptop camera's field of view.

Before adding anything to the function you can call it to get a hang of how it works - a small window will pop up showing you the live feed from your camera, you can press any key to close this window.

Note: Mac users may find that activating this function kills the kernel of their notebook every once in a while. If this happens to you, just restart your notebook's kernel, activate cell(s) containing any crucial import statements, and you'll be good to go!


In [17]:
### Insert face detection and blurring code into the wrapper below to create an identity protector on your laptop!
import cv2
import time

# tweaked to my camera / lighting at the time of development
def denoiser_laptop(image):
    return cv2.fastNlMeansDenoisingColored(image, None, 20, 20, 21, 7)

def laptop_camera_go():
    # Create instance of video capturer
    cv2.namedWindow("face detection activated")
    vc = cv2.VideoCapture(0)

    # Try to get the first frame
    if vc.isOpened(): 
        rval, frame = vc.read()
    else:
        rval = False
    
    # Keep video stream open
    while rval:
        # Plot image from camera with detections marked
        blur_frame = blur_face(frame, denoiser_laptop)
        cv2.imshow("face detection activated", blur_frame)
        
        # Exit functionality - press any key to exit laptop video
        key = cv2.waitKey(20)
        if key > 0: # Exit by pressing any key
            # Destroy windows
            cv2.destroyAllWindows()
            
            for i in range (1,5):
                cv2.waitKey(1)
            return
        
        # Read next frame
        time.sleep(0.05)             # control framerate for computation - default 20 frames per sec
        rval, frame = vc.read()

In [18]:
# Run laptop identity hider
# laptop_camera_go()

Pretty Cool


Step 5: Create a CNN to Recognize Facial Keypoints

OpenCV is often used in practice with other machine learning and deep learning libraries to produce interesting results. In this stage of the project you will create your own end-to-end pipeline - employing convolutional networks in keras along with OpenCV - to apply a "selfie" filter to streaming video and images.

You will start by creating and then training a convolutional network that can detect facial keypoints in a small dataset of cropped images of human faces. We then guide you towards OpenCV to expanding your detection algorithm to more general images. What are facial keypoints? Let's take a look at some examples.

Facial keypoints (also called facial landmarks) are the small blue-green dots shown on each of the faces in the image above - there are 15 keypoints marked in each image. They mark important areas of the face - the eyes, corners of the mouth, the nose, etc. Facial keypoints can be used in a variety of machine learning applications from face and emotion recognition to commercial applications like the image filters popularized by Snapchat.

Below we illustrate a filter that, using the results of this section, automatically places sunglasses on people in images (using the facial keypoints to place the glasses correctly on each face). Here, the facial keypoints have been colored lime green for visualization purposes.

Make a facial keypoint detector

But first things first: how can we make a facial keypoint detector? Well, at a high level, notice that facial keypoint detection is a regression problem. A single face corresponds to a set of 15 facial keypoints (a set of 15 corresponding $(x, y)$ coordinates, i.e., an output point). Because our input data are images, we can employ a convolutional neural network to recognize patterns in our images and learn how to identify these keypoint given sets of labeled data.

In order to train a regressor, we need a training set - a set of facial image / facial keypoint pairs to train on. For this we will be using this dataset from Kaggle. We've already downloaded this data and placed it in the data directory. Make sure that you have both the training and test data files. The training dataset contains several thousand $96 \times 96$ grayscale images of cropped human faces, along with each face's 15 corresponding facial keypoints (also called landmarks) that have been placed by hand, and recorded in $(x, y)$ coordinates. This wonderful resource also has a substantial testing set, which we will use in tinkering with our convolutional network.

To load in this data, run the Python cell below - notice we will load in both the training and testing sets.

The load_data function is in the included utils.py file.


In [19]:
from utils import *

# Load training set
X_train, y_train = load_data()
print("X_train.shape == {}".format(X_train.shape))
print("y_train.shape == {}; y_train.min == {:.3f}; y_train.max == {:.3f}".format(
    y_train.shape, y_train.min(), y_train.max()))

# Load testing set
X_test, _ = load_data(test=True)
print("X_test.shape == {}".format(X_test.shape))


Using TensorFlow backend.
X_train.shape == (2140, 96, 96, 1)
y_train.shape == (2140, 30); y_train.min == -0.920; y_train.max == 0.996
X_test.shape == (1783, 96, 96, 1)

The load_data function in utils.py originates from this excellent blog post, which you are strongly encouraged to read. Please take the time now to review this function. Note how the output values - that is, the coordinates of each set of facial landmarks - have been normalized to take on values in the range $[-1, 1]$, while the pixel values of each input point (a facial image) have been normalized to the range $[0,1]$.

Note: the original Kaggle dataset contains some images with several missing keypoints. For simplicity, the load_data function removes those images with missing labels from the dataset. As an optional extension, you are welcome to amend the load_data function to include the incomplete data points.

Visualize the Training Data

Execute the code cell below to visualize a subset of the training data.


In [20]:
import matplotlib.pyplot as plt
%matplotlib inline

fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(9):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    plot_data(X_train[i], y_train[i], ax)


For each training image, there are two landmarks per eyebrow (four total), three per eye (six total), four for the mouth, and one for the tip of the nose.

Review the plot_data function in utils.py to understand how the 30-dimensional training labels in y_train are mapped to facial locations, as this function will prove useful for your pipeline.

(IMPLEMENTATION) Specify the CNN Architecture

In this section, you will specify a neural network for predicting the locations of facial keypoints. Use the code cell below to specify the architecture of your neural network. We have imported some layers that you may find useful for this task, but if you need to use more Keras layers, feel free to import them in the cell.

Your network should accept a $96 \times 96$ grayscale image as input, and it should output a vector with 30 entries, corresponding to the predicted (horizontal and vertical) locations of 15 facial keypoints. If you are not sure where to start, you can find some useful starting architectures in this blog, but you are not permitted to copy any of the architectures that you find online.


In [21]:
# helpers for training CNNs
import keras
import timeit

# graph the history of model.fit
def show_history_graph(history, extra=''):
    # summarize history for accuracy
    print(history.history.keys())
    plt.plot(history.history['acc'])
    plt.plot(history.history['val_acc'])
    plt.title(f'model accuracy {extra}')
    plt.ylabel('accuracy')
    plt.xlabel('epoch')
    plt.legend(['train', 'test'], loc='upper right')
    plt.show()

    # summarize history for mean absolute error
    plt.plot(history.history['mean_absolute_error'])
    plt.plot(history.history['val_mean_absolute_error'])
    plt.title(f'model mean absolute error {extra}')
    plt.ylabel('error')
    plt.xlabel('epoch')
    plt.legend(['train', 'test'], loc='upper right')
    plt.show()
    
    # summarize history for mean absolute error
    plt.plot(history.history['mean_squared_error'])
    plt.plot(history.history['val_mean_squared_error'])
    plt.title(f'model mean squared error {extra}')
    plt.ylabel('error')
    plt.xlabel('epoch')
    plt.legend(['train', 'test'], loc='upper right')
    plt.show()

    # summarize history for loss
    plt.plot(history.history['loss'])
    plt.plot(history.history['val_loss'])
    plt.title(f'model loss {extra}')
    plt.ylabel('loss')
    plt.xlabel('epoch')
    plt.legend(['train', 'test'], loc='upper right')
    plt.show()

In [22]:
# Import deep learning resources from Keras
from keras.models import Sequential
from keras.layers import Convolution2D, MaxPooling2D, Dropout
from keras.layers import Flatten, Dense

# TODO: Specify a CNN architecture
# Your model should accept 96x96 pixel graysale images in
# It should have a fully-connected output layer with 30 values (2 for each facial keypoint)

# This is the lasagne network from:
# http://danielnouri.org/notes/2014/12/17/using-convolutional-neural-nets-to-detect-facial-keypoints-tutorial/
# pretty straight forwards Conv2D Max Pool type CNN network 

# layers=[
#     ('input', layers.InputLayer),
#     ('conv1', layers.Conv2DLayer),
#     ('pool1', layers.MaxPool2DLayer),
#     ('conv2', layers.Conv2DLayer),
#     ('pool2', layers.MaxPool2DLayer),
#     ('conv3', layers.Conv2DLayer),
#     ('pool3', layers.MaxPool2DLayer),
#     ('hidden4', layers.DenseLayer),
#     ('hidden5', layers.DenseLayer),
#     ('output', layers.DenseLayer),
#     ],
# input_shape=(None, 1, 96, 96),
# conv1_num_filters=32, conv1_filter_size=(3, 3), pool1_pool_size=(2, 2),
# conv2_num_filters=64, conv2_filter_size=(2, 2), pool2_pool_size=(2, 2),
# conv3_num_filters=128, conv3_filter_size=(2, 2), pool3_pool_size=(2, 2),
# hidden4_num_units=500, hidden5_num_units=500,
# output_num_units=30, output_nonlinearity=None,

model = Sequential()
model.add(Convolution2D(filters=32, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Convolution2D(filters=128, kernel_size=(2, 2), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())
model.add(Dense(512)) # base 2 rather than 500 in lasagne network
model.add(Dense(512)) # base 2 rather than 500 in lasagne network
model.add(Dense(30))

# Summarize the model
model.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 94, 94, 32)        320       
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 47, 47, 32)        0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 46, 46, 64)        8256      
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 23, 23, 64)        0         
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 22, 22, 128)       32896     
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 11, 11, 128)       0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 15488)             0         
_________________________________________________________________
dense_1 (Dense)              (None, 512)               7930368   
_________________________________________________________________
dense_2 (Dense)              (None, 512)               262656    
_________________________________________________________________
dense_3 (Dense)              (None, 30)                15390     
=================================================================
Total params: 8,249,886
Trainable params: 8,249,886
Non-trainable params: 0
_________________________________________________________________

Step 6: Compile and Train the Model

After specifying your architecture, you'll need to compile and train the model to detect facial keypoints'

(IMPLEMENTATION) Compile and Train the Model

Use the compile method to configure the learning process. Experiment with your choice of optimizer; you may have some ideas about which will work best (SGD vs. RMSprop, etc), but take the time to empirically verify your theories.

Use the fit method to train the model. Break off a validation set by setting validation_split=0.2. Save the returned History object in the history variable.

Your model is required to attain a validation loss (measured as mean squared error) of at least XYZ. When you have finished training, save your model as an HDF5 file with file path my_model.h5.


In [23]:
from keras.optimizers import SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam

optimizers = ['SGD', 'RMSprop', 'Adagrad', 'Adadelta', 'Adam', 'Adamax', 'Nadam', 'Nesterov']
mse_history = {}
epochs = 10
for optimizer in optimizers:
    # the lasagne network suggested using SGD Nesterov with lr 0.01 and momentum 0.9
    # CS231n Recommends: http://cs231n.github.io/neural-networks-3/#summary
    # The two recommended updates to use are either SGD+Nesterov Momentum or Adam.
    if optimizer == 'Nesterov':
        opt = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
    else:
        opt = optimizer
    model.compile(loss='mean_squared_error', optimizer=opt, metrics=['mse'])
    hist = model.fit(X_train, y_train, validation_split=0.2, epochs=epochs, verbose=0)
    mse_history[optimizer] = hist.history['mean_squared_error']

In [24]:
legend = []
plt.figure(figsize=(20, 10))
for key, opt in mse_history.items():
    plt.plot(opt)
    legend.append(key)

plt.title(f'optimizer mean squared error')
plt.ylabel('mean squared error')
plt.xlabel('epoch')
plt.legend(legend, loc='upper right')
plt.ylim(0, 0.01)
plt.show()



In [ ]:
# Adam / Adamax seem to be doing the best here

In [31]:
model2 = Sequential()
model2.add(Convolution2D(filters=32, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model2.add(MaxPooling2D(pool_size=(2, 2)))

model2.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model2.add(MaxPooling2D(pool_size=(2, 2)))

model2.add(Convolution2D(filters=128, kernel_size=(2, 2), activation='relu'))
model2.add(MaxPooling2D(pool_size=(2, 2)))

model2.add(Flatten())
model2.add(Dense(512)) # base 2 rather than 500 in lasagne network
model2.add(Dense(512)) # base 2 rather than 500 in lasagne network
model2.add(Dense(30))

# Summarize the model
model2.summary()

opt = 'Adamax'
epochs = 10
model2.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model2.fit(X_train, y_train, validation_split=0.2, epochs=epochs, shuffle=True)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_10 (Conv2D)           (None, 94, 94, 32)        320       
_________________________________________________________________
max_pooling2d_10 (MaxPooling (None, 47, 47, 32)        0         
_________________________________________________________________
conv2d_11 (Conv2D)           (None, 46, 46, 64)        8256      
_________________________________________________________________
max_pooling2d_11 (MaxPooling (None, 23, 23, 64)        0         
_________________________________________________________________
conv2d_12 (Conv2D)           (None, 22, 22, 128)       32896     
_________________________________________________________________
max_pooling2d_12 (MaxPooling (None, 11, 11, 128)       0         
_________________________________________________________________
flatten_4 (Flatten)          (None, 15488)             0         
_________________________________________________________________
dense_9 (Dense)              (None, 512)               7930368   
_________________________________________________________________
dense_10 (Dense)             (None, 512)               262656    
_________________________________________________________________
dense_11 (Dense)             (None, 30)                15390     
=================================================================
Total params: 8,249,886
Trainable params: 8,249,886
Non-trainable params: 0
_________________________________________________________________
Train on 1712 samples, validate on 428 samples
Epoch 1/10
1712/1712 [==============================] - 2s - loss: 0.1080 - acc: 0.5736 - mean_absolute_error: 0.1509 - mean_squared_error: 0.1080 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0520 - val_mean_squared_error: 0.0049
Epoch 2/10
1712/1712 [==============================] - 1s - loss: 0.0038 - acc: 0.7103 - mean_absolute_error: 0.0448 - mean_squared_error: 0.0038 - val_loss: 0.0033 - val_acc: 0.7126 - val_mean_absolute_error: 0.0431 - val_mean_squared_error: 0.0033
Epoch 3/10
1712/1712 [==============================] - 1s - loss: 0.0024 - acc: 0.7231 - mean_absolute_error: 0.0349 - mean_squared_error: 0.0024 - val_loss: 0.0021 - val_acc: 0.7243 - val_mean_absolute_error: 0.0330 - val_mean_squared_error: 0.0021
Epoch 4/10
1712/1712 [==============================] - 1s - loss: 0.0018 - acc: 0.7442 - mean_absolute_error: 0.0305 - mean_squared_error: 0.0018 - val_loss: 0.0019 - val_acc: 0.7313 - val_mean_absolute_error: 0.0313 - val_mean_squared_error: 0.0019
Epoch 5/10
1712/1712 [==============================] - 1s - loss: 0.0015 - acc: 0.7547 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0015 - val_loss: 0.0017 - val_acc: 0.7407 - val_mean_absolute_error: 0.0288 - val_mean_squared_error: 0.0017
Epoch 6/10
1712/1712 [==============================] - 1s - loss: 0.0013 - acc: 0.7652 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0013 - val_loss: 0.0016 - val_acc: 0.7640 - val_mean_absolute_error: 0.0288 - val_mean_squared_error: 0.0016
Epoch 7/10
1712/1712 [==============================] - 1s - loss: 0.0012 - acc: 0.7786 - mean_absolute_error: 0.0244 - mean_squared_error: 0.0012 - val_loss: 0.0015 - val_acc: 0.7757 - val_mean_absolute_error: 0.0271 - val_mean_squared_error: 0.0015
Epoch 8/10
1712/1712 [==============================] - 1s - loss: 0.0011 - acc: 0.7804 - mean_absolute_error: 0.0236 - mean_squared_error: 0.0011 - val_loss: 0.0016 - val_acc: 0.7617 - val_mean_absolute_error: 0.0280 - val_mean_squared_error: 0.0016
Epoch 9/10
1712/1712 [==============================] - 1s - loss: 9.7719e-04 - acc: 0.7985 - mean_absolute_error: 0.0224 - mean_squared_error: 9.7719e-04 - val_loss: 0.0015 - val_acc: 0.7687 - val_mean_absolute_error: 0.0271 - val_mean_squared_error: 0.0015
Epoch 10/10
1712/1712 [==============================] - 1s - loss: 9.1599e-04 - acc: 0.8107 - mean_absolute_error: 0.0219 - mean_squared_error: 9.1599e-04 - val_loss: 0.0014 - val_acc: 0.7687 - val_mean_absolute_error: 0.0268 - val_mean_squared_error: 0.0014
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:
# Seems to be converging okay, lets try adding some dropout

In [32]:
model3 = Sequential()
model3.add(Convolution2D(filters=32, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model3.add(MaxPooling2D(pool_size=(2, 2)))
model3.add(Dropout(0.5))

model3.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model3.add(MaxPooling2D(pool_size=(2, 2)))
model3.add(Dropout(0.5))

model3.add(Convolution2D(filters=128, kernel_size=(2, 2), activation='relu'))
model3.add(MaxPooling2D(pool_size=(2, 2)))
model3.add(Dropout(0.5))

model3.add(Flatten())
model3.add(Dense(512)) # base 2 rather than 500 in lasagne network
model3.add(Dropout(0.5))
model3.add(Dense(512)) # base 2 rather than 500 in lasagne network
model3.add(Dropout(0.5))
model3.add(Dense(30))

# Summarize the model
model3.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_13 (Conv2D)           (None, 94, 94, 32)        320       
_________________________________________________________________
max_pooling2d_13 (MaxPooling (None, 47, 47, 32)        0         
_________________________________________________________________
dropout_10 (Dropout)         (None, 47, 47, 32)        0         
_________________________________________________________________
conv2d_14 (Conv2D)           (None, 46, 46, 64)        8256      
_________________________________________________________________
max_pooling2d_14 (MaxPooling (None, 23, 23, 64)        0         
_________________________________________________________________
dropout_11 (Dropout)         (None, 23, 23, 64)        0         
_________________________________________________________________
conv2d_15 (Conv2D)           (None, 22, 22, 128)       32896     
_________________________________________________________________
max_pooling2d_15 (MaxPooling (None, 11, 11, 128)       0         
_________________________________________________________________
dropout_12 (Dropout)         (None, 11, 11, 128)       0         
_________________________________________________________________
flatten_5 (Flatten)          (None, 15488)             0         
_________________________________________________________________
dense_12 (Dense)             (None, 512)               7930368   
_________________________________________________________________
dropout_13 (Dropout)         (None, 512)               0         
_________________________________________________________________
dense_13 (Dense)             (None, 512)               262656    
_________________________________________________________________
dropout_14 (Dropout)         (None, 512)               0         
_________________________________________________________________
dense_14 (Dense)             (None, 30)                15390     
=================================================================
Total params: 8,249,886
Trainable params: 8,249,886
Non-trainable params: 0
_________________________________________________________________

In [33]:
opt = 'Adamax'
epochs = 10
model3.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model3.fit(X_train, y_train, validation_split=0.2, epochs=epochs, shuffle=True)
show_history_graph(hist)


Train on 1712 samples, validate on 428 samples
Epoch 1/10
1712/1712 [==============================] - 2s - loss: 0.7881 - acc: 0.1501 - mean_absolute_error: 0.4557 - mean_squared_error: 0.7881 - val_loss: 0.1286 - val_acc: 0.2523 - val_mean_absolute_error: 0.3100 - val_mean_squared_error: 0.1286
Epoch 2/10
1712/1712 [==============================] - 2s - loss: 0.0462 - acc: 0.2763 - mean_absolute_error: 0.1709 - mean_squared_error: 0.0462 - val_loss: 0.1081 - val_acc: 0.2523 - val_mean_absolute_error: 0.2836 - val_mean_squared_error: 0.1081
Epoch 3/10
1712/1712 [==============================] - 2s - loss: 0.0345 - acc: 0.3137 - mean_absolute_error: 0.1476 - mean_squared_error: 0.0345 - val_loss: 0.0838 - val_acc: 0.2523 - val_mean_absolute_error: 0.2485 - val_mean_squared_error: 0.0838
Epoch 4/10
1712/1712 [==============================] - 2s - loss: 0.0284 - acc: 0.3254 - mean_absolute_error: 0.1336 - mean_squared_error: 0.0284 - val_loss: 0.0734 - val_acc: 0.2523 - val_mean_absolute_error: 0.2315 - val_mean_squared_error: 0.0734
Epoch 5/10
1712/1712 [==============================] - 2s - loss: 0.0251 - acc: 0.3376 - mean_absolute_error: 0.1261 - mean_squared_error: 0.0251 - val_loss: 0.0715 - val_acc: 0.3668 - val_mean_absolute_error: 0.2287 - val_mean_squared_error: 0.0715
Epoch 6/10
1712/1712 [==============================] - 2s - loss: 0.0229 - acc: 0.3546 - mean_absolute_error: 0.1199 - mean_squared_error: 0.0229 - val_loss: 0.0635 - val_acc: 0.3201 - val_mean_absolute_error: 0.2148 - val_mean_squared_error: 0.0635
Epoch 7/10
1712/1712 [==============================] - 2s - loss: 0.0209 - acc: 0.3814 - mean_absolute_error: 0.1143 - mean_squared_error: 0.0209 - val_loss: 0.0571 - val_acc: 0.5888 - val_mean_absolute_error: 0.2033 - val_mean_squared_error: 0.0571
Epoch 8/10
1712/1712 [==============================] - 2s - loss: 0.0195 - acc: 0.4019 - mean_absolute_error: 0.1105 - mean_squared_error: 0.0195 - val_loss: 0.0539 - val_acc: 0.6495 - val_mean_absolute_error: 0.1970 - val_mean_squared_error: 0.0539
Epoch 9/10
1712/1712 [==============================] - 2s - loss: 0.0182 - acc: 0.3855 - mean_absolute_error: 0.1065 - mean_squared_error: 0.0182 - val_loss: 0.0467 - val_acc: 0.6776 - val_mean_absolute_error: 0.1822 - val_mean_squared_error: 0.0467
Epoch 10/10
1712/1712 [==============================] - 2s - loss: 0.0174 - acc: 0.4200 - mean_absolute_error: 0.1042 - mean_squared_error: 0.0174 - val_loss: 0.0416 - val_acc: 0.6916 - val_mean_absolute_error: 0.1714 - val_mean_squared_error: 0.0416
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [34]:
# something weird going on lets try more dimensionality reduction

In [35]:
model4 = Sequential()
model4.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model4.add(MaxPooling2D(pool_size=(2, 2)))
model4.add(Dropout(0.5))

model4.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model4.add(MaxPooling2D(pool_size=(2, 2)))
model4.add(Dropout(0.5))

model4.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model4.add(MaxPooling2D(pool_size=(2, 2)))
model4.add(Dropout(0.5))

model4.add(Flatten())
model4.add(Dense(512)) # base 2 rather than 500 in lasagne network
model4.add(Dropout(0.5))
model4.add(Dense(30))

# Summarize the model
model4.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_16 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_16 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_15 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_17 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_17 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_16 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_18 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_18 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_17 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_6 (Flatten)          (None, 7744)              0         
_________________________________________________________________
dense_15 (Dense)             (None, 512)               3965440   
_________________________________________________________________
dropout_18 (Dropout)         (None, 512)               0         
_________________________________________________________________
dense_16 (Dense)             (None, 30)                15390     
=================================================================
Total params: 3,991,326
Trainable params: 3,991,326
Non-trainable params: 0
_________________________________________________________________

In [36]:
opt = 'Adamax'
epochs = 10
model4.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model4.fit(X_train, y_train, validation_split=0.2, epochs=epochs, shuffle=True)
show_history_graph(hist)


Train on 1712 samples, validate on 428 samples
Epoch 1/10
1712/1712 [==============================] - 1s - loss: 1.0855 - acc: 0.1688 - mean_absolute_error: 0.5544 - mean_squared_error: 1.0855 - val_loss: 0.1437 - val_acc: 0.1051 - val_mean_absolute_error: 0.3273 - val_mean_squared_error: 0.1437
Epoch 2/10
1712/1712 [==============================] - 1s - loss: 0.0601 - acc: 0.2810 - mean_absolute_error: 0.1943 - mean_squared_error: 0.0601 - val_loss: 0.1398 - val_acc: 0.2570 - val_mean_absolute_error: 0.3230 - val_mean_squared_error: 0.1398
Epoch 3/10
1712/1712 [==============================] - 1s - loss: 0.0460 - acc: 0.3224 - mean_absolute_error: 0.1702 - mean_squared_error: 0.0460 - val_loss: 0.1139 - val_acc: 0.6706 - val_mean_absolute_error: 0.2912 - val_mean_squared_error: 0.1139
Epoch 4/10
1712/1712 [==============================] - 1s - loss: 0.0348 - acc: 0.3546 - mean_absolute_error: 0.1475 - mean_squared_error: 0.0348 - val_loss: 0.0895 - val_acc: 0.6963 - val_mean_absolute_error: 0.2580 - val_mean_squared_error: 0.0895
Epoch 5/10
1712/1712 [==============================] - 1s - loss: 0.0273 - acc: 0.3803 - mean_absolute_error: 0.1307 - mean_squared_error: 0.0273 - val_loss: 0.0790 - val_acc: 0.6963 - val_mean_absolute_error: 0.2413 - val_mean_squared_error: 0.0790
Epoch 6/10
1712/1712 [==============================] - 1s - loss: 0.0229 - acc: 0.4048 - mean_absolute_error: 0.1197 - mean_squared_error: 0.0229 - val_loss: 0.0770 - val_acc: 0.6963 - val_mean_absolute_error: 0.2374 - val_mean_squared_error: 0.0770
Epoch 7/10
1712/1712 [==============================] - 1s - loss: 0.0207 - acc: 0.4252 - mean_absolute_error: 0.1138 - mean_squared_error: 0.0207 - val_loss: 0.0651 - val_acc: 0.6963 - val_mean_absolute_error: 0.2178 - val_mean_squared_error: 0.0651
Epoch 8/10
1712/1712 [==============================] - 1s - loss: 0.0186 - acc: 0.4106 - mean_absolute_error: 0.1081 - mean_squared_error: 0.0186 - val_loss: 0.0611 - val_acc: 0.6963 - val_mean_absolute_error: 0.2106 - val_mean_squared_error: 0.0611
Epoch 9/10
1712/1712 [==============================] - 1s - loss: 0.0174 - acc: 0.4457 - mean_absolute_error: 0.1042 - mean_squared_error: 0.0174 - val_loss: 0.0540 - val_acc: 0.6963 - val_mean_absolute_error: 0.1974 - val_mean_squared_error: 0.0540
Epoch 10/10
1712/1712 [==============================] - 1s - loss: 0.0164 - acc: 0.4585 - mean_absolute_error: 0.1009 - mean_squared_error: 0.0164 - val_loss: 0.0468 - val_acc: 0.6963 - val_mean_absolute_error: 0.1830 - val_mean_squared_error: 0.0468
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [37]:
# lets reduce it more

In [38]:
model5 = Sequential()
model5.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model5.add(MaxPooling2D(pool_size=(2, 2)))
model5.add(Dropout(0.5))

model5.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model5.add(MaxPooling2D(pool_size=(2, 2)))
model5.add(Dropout(0.5))

model5.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model5.add(MaxPooling2D(pool_size=(2, 2)))
model5.add(Dropout(0.5))

model5.add(Flatten())
model5.add(Dense(256))
model5.add(Dropout(0.5))
model5.add(Dense(30))

# Summarize the model
model5.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_19 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_19 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_19 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_20 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_20 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_20 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_21 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_21 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_21 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_7 (Flatten)          (None, 7744)              0         
_________________________________________________________________
dense_17 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_22 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_18 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________

In [ ]:


In [39]:
opt = 'Adamax'
epochs = 30
model5.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model5.fit(X_train, y_train, validation_split=0.2, epochs=epochs, shuffle=True)
show_history_graph(hist)


Train on 1712 samples, validate on 428 samples
Epoch 1/30
1712/1712 [==============================] - 1s - loss: 0.2000 - acc: 0.2243 - mean_absolute_error: 0.2833 - mean_squared_error: 0.2000 - val_loss: 0.1364 - val_acc: 0.0000e+00 - val_mean_absolute_error: 0.3177 - val_mean_squared_error: 0.1364
Epoch 2/30
1712/1712 [==============================] - 1s - loss: 0.0389 - acc: 0.3294 - mean_absolute_error: 0.1566 - mean_squared_error: 0.0389 - val_loss: 0.1170 - val_acc: 0.1051 - val_mean_absolute_error: 0.2926 - val_mean_squared_error: 0.1170
Epoch 3/30
1712/1712 [==============================] - 1s - loss: 0.0280 - acc: 0.3411 - mean_absolute_error: 0.1326 - mean_squared_error: 0.0280 - val_loss: 0.0682 - val_acc: 0.6519 - val_mean_absolute_error: 0.2183 - val_mean_squared_error: 0.0682
Epoch 4/30
1712/1712 [==============================] - 1s - loss: 0.0234 - acc: 0.3709 - mean_absolute_error: 0.1212 - mean_squared_error: 0.0234 - val_loss: 0.0529 - val_acc: 0.6776 - val_mean_absolute_error: 0.1918 - val_mean_squared_error: 0.0529
Epoch 5/30
1712/1712 [==============================] - 1s - loss: 0.0206 - acc: 0.3727 - mean_absolute_error: 0.1139 - mean_squared_error: 0.0206 - val_loss: 0.0416 - val_acc: 0.6963 - val_mean_absolute_error: 0.1694 - val_mean_squared_error: 0.0416
Epoch 6/30
1712/1712 [==============================] - 1s - loss: 0.0190 - acc: 0.3884 - mean_absolute_error: 0.1089 - mean_squared_error: 0.0190 - val_loss: 0.0300 - val_acc: 0.6963 - val_mean_absolute_error: 0.1414 - val_mean_squared_error: 0.0300
Epoch 7/30
1712/1712 [==============================] - 1s - loss: 0.0176 - acc: 0.4235 - mean_absolute_error: 0.1051 - mean_squared_error: 0.0176 - val_loss: 0.0254 - val_acc: 0.6963 - val_mean_absolute_error: 0.1291 - val_mean_squared_error: 0.0254
Epoch 8/30
1712/1712 [==============================] - 1s - loss: 0.0165 - acc: 0.4229 - mean_absolute_error: 0.1013 - mean_squared_error: 0.0165 - val_loss: 0.0245 - val_acc: 0.6963 - val_mean_absolute_error: 0.1274 - val_mean_squared_error: 0.0245
Epoch 9/30
1712/1712 [==============================] - 1s - loss: 0.0153 - acc: 0.4322 - mean_absolute_error: 0.0976 - mean_squared_error: 0.0153 - val_loss: 0.0200 - val_acc: 0.6963 - val_mean_absolute_error: 0.1136 - val_mean_squared_error: 0.0200
Epoch 10/30
1712/1712 [==============================] - 1s - loss: 0.0147 - acc: 0.4398 - mean_absolute_error: 0.0957 - mean_squared_error: 0.0147 - val_loss: 0.0159 - val_acc: 0.6963 - val_mean_absolute_error: 0.0995 - val_mean_squared_error: 0.0159
Epoch 11/30
1712/1712 [==============================] - 1s - loss: 0.0139 - acc: 0.4714 - mean_absolute_error: 0.0924 - mean_squared_error: 0.0139 - val_loss: 0.0166 - val_acc: 0.6963 - val_mean_absolute_error: 0.1033 - val_mean_squared_error: 0.0166
Epoch 12/30
1712/1712 [==============================] - 1s - loss: 0.0133 - acc: 0.4550 - mean_absolute_error: 0.0906 - mean_squared_error: 0.0133 - val_loss: 0.0132 - val_acc: 0.6963 - val_mean_absolute_error: 0.0905 - val_mean_squared_error: 0.0132
Epoch 13/30
1712/1712 [==============================] - 1s - loss: 0.0126 - acc: 0.4755 - mean_absolute_error: 0.0883 - mean_squared_error: 0.0126 - val_loss: 0.0123 - val_acc: 0.6963 - val_mean_absolute_error: 0.0865 - val_mean_squared_error: 0.0123
Epoch 14/30
1712/1712 [==============================] - 1s - loss: 0.0122 - acc: 0.4912 - mean_absolute_error: 0.0867 - mean_squared_error: 0.0122 - val_loss: 0.0098 - val_acc: 0.6963 - val_mean_absolute_error: 0.0759 - val_mean_squared_error: 0.0098
Epoch 15/30
1712/1712 [==============================] - 1s - loss: 0.0118 - acc: 0.4877 - mean_absolute_error: 0.0853 - mean_squared_error: 0.0118 - val_loss: 0.0086 - val_acc: 0.6963 - val_mean_absolute_error: 0.0704 - val_mean_squared_error: 0.0086
Epoch 16/30
1712/1712 [==============================] - 1s - loss: 0.0113 - acc: 0.4912 - mean_absolute_error: 0.0831 - mean_squared_error: 0.0113 - val_loss: 0.0080 - val_acc: 0.6963 - val_mean_absolute_error: 0.0680 - val_mean_squared_error: 0.0080
Epoch 17/30
1712/1712 [==============================] - 1s - loss: 0.0111 - acc: 0.5035 - mean_absolute_error: 0.0820 - mean_squared_error: 0.0111 - val_loss: 0.0074 - val_acc: 0.6963 - val_mean_absolute_error: 0.0652 - val_mean_squared_error: 0.0074
Epoch 18/30
1712/1712 [==============================] - 1s - loss: 0.0108 - acc: 0.5193 - mean_absolute_error: 0.0810 - mean_squared_error: 0.0108 - val_loss: 0.0062 - val_acc: 0.6963 - val_mean_absolute_error: 0.0586 - val_mean_squared_error: 0.0062
Epoch 19/30
1712/1712 [==============================] - 1s - loss: 0.0103 - acc: 0.5275 - mean_absolute_error: 0.0789 - mean_squared_error: 0.0103 - val_loss: 0.0060 - val_acc: 0.6963 - val_mean_absolute_error: 0.0578 - val_mean_squared_error: 0.0060
Epoch 20/30
1712/1712 [==============================] - 1s - loss: 0.0099 - acc: 0.5275 - mean_absolute_error: 0.0775 - mean_squared_error: 0.0099 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0552 - val_mean_squared_error: 0.0056
Epoch 21/30
1712/1712 [==============================] - 1s - loss: 0.0097 - acc: 0.5391 - mean_absolute_error: 0.0764 - mean_squared_error: 0.0097 - val_loss: 0.0068 - val_acc: 0.6963 - val_mean_absolute_error: 0.0619 - val_mean_squared_error: 0.0068
Epoch 22/30
1712/1712 [==============================] - 1s - loss: 0.0093 - acc: 0.5724 - mean_absolute_error: 0.0750 - mean_squared_error: 0.0093 - val_loss: 0.0060 - val_acc: 0.6963 - val_mean_absolute_error: 0.0575 - val_mean_squared_error: 0.0060
Epoch 23/30
1712/1712 [==============================] - 1s - loss: 0.0090 - acc: 0.5654 - mean_absolute_error: 0.0735 - mean_squared_error: 0.0090 - val_loss: 0.0061 - val_acc: 0.6963 - val_mean_absolute_error: 0.0583 - val_mean_squared_error: 0.0061
Epoch 24/30
1712/1712 [==============================] - 1s - loss: 0.0087 - acc: 0.5526 - mean_absolute_error: 0.0721 - mean_squared_error: 0.0087 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0552 - val_mean_squared_error: 0.0056
Epoch 25/30
1712/1712 [==============================] - 1s - loss: 0.0085 - acc: 0.5812 - mean_absolute_error: 0.0712 - mean_squared_error: 0.0085 - val_loss: 0.0054 - val_acc: 0.6963 - val_mean_absolute_error: 0.0541 - val_mean_squared_error: 0.0054
Epoch 26/30
1712/1712 [==============================] - 1s - loss: 0.0082 - acc: 0.5900 - mean_absolute_error: 0.0697 - mean_squared_error: 0.0082 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0503 - val_mean_squared_error: 0.0047
Epoch 27/30
1712/1712 [==============================] - 1s - loss: 0.0081 - acc: 0.5748 - mean_absolute_error: 0.0694 - mean_squared_error: 0.0081 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0514 - val_mean_squared_error: 0.0049
Epoch 28/30
1712/1712 [==============================] - 1s - loss: 0.0077 - acc: 0.5824 - mean_absolute_error: 0.0676 - mean_squared_error: 0.0077 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0494 - val_mean_squared_error: 0.0046
Epoch 29/30
1712/1712 [==============================] - 1s - loss: 0.0075 - acc: 0.5818 - mean_absolute_error: 0.0668 - mean_squared_error: 0.0075 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0495 - val_mean_squared_error: 0.0046
Epoch 30/30
1712/1712 [==============================] - 1s - loss: 0.0074 - acc: 0.6110 - mean_absolute_error: 0.0659 - mean_squared_error: 0.0074 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [41]:
model6 = Sequential()
model6.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model6.add(MaxPooling2D(pool_size=(2, 2)))
model6.add(Dropout(0.5))

model6.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model6.add(MaxPooling2D(pool_size=(2, 2)))
model6.add(Dropout(0.5))

model6.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model6.add(MaxPooling2D(pool_size=(2, 2)))
model6.add(Dropout(0.5))

model6.add(Flatten())
model6.add(Dense(256))
model6.add(Dropout(0.5))
model6.add(Dense(30))

# Summarize the model
model6.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_25 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_25 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_28 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_26 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_26 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_29 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_27 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_27 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_30 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_9 (Flatten)          (None, 7744)              0         
_________________________________________________________________
dense_22 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_31 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_23 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________

In [42]:
# lets see nesterov momentum for comparison

In [43]:
opt = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
epochs = 30
model6.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model6.fit(X_train, y_train, validation_split=0.2, epochs=epochs, shuffle=True)
show_history_graph(hist)


Train on 1712 samples, validate on 428 samples
Epoch 1/30
1712/1712 [==============================] - 1s - loss: 0.0522 - acc: 0.3043 - mean_absolute_error: 0.1584 - mean_squared_error: 0.0522 - val_loss: 0.0249 - val_acc: 0.6963 - val_mean_absolute_error: 0.1306 - val_mean_squared_error: 0.0249
Epoch 2/30
1712/1712 [==============================] - 1s - loss: 0.0171 - acc: 0.4241 - mean_absolute_error: 0.1034 - mean_squared_error: 0.0171 - val_loss: 0.0146 - val_acc: 0.6963 - val_mean_absolute_error: 0.0976 - val_mean_squared_error: 0.0146
Epoch 3/30
1712/1712 [==============================] - 1s - loss: 0.0148 - acc: 0.4509 - mean_absolute_error: 0.0960 - mean_squared_error: 0.0148 - val_loss: 0.0118 - val_acc: 0.6963 - val_mean_absolute_error: 0.0861 - val_mean_squared_error: 0.0118
Epoch 4/30
1712/1712 [==============================] - 1s - loss: 0.0133 - acc: 0.4761 - mean_absolute_error: 0.0908 - mean_squared_error: 0.0133 - val_loss: 0.0074 - val_acc: 0.6963 - val_mean_absolute_error: 0.0657 - val_mean_squared_error: 0.0074
Epoch 5/30
1712/1712 [==============================] - 1s - loss: 0.0123 - acc: 0.4889 - mean_absolute_error: 0.0872 - mean_squared_error: 0.0123 - val_loss: 0.0075 - val_acc: 0.6963 - val_mean_absolute_error: 0.0661 - val_mean_squared_error: 0.0075
Epoch 6/30
1712/1712 [==============================] - 1s - loss: 0.0113 - acc: 0.5053 - mean_absolute_error: 0.0834 - mean_squared_error: 0.0113 - val_loss: 0.0067 - val_acc: 0.6963 - val_mean_absolute_error: 0.0617 - val_mean_squared_error: 0.0067
Epoch 7/30
1712/1712 [==============================] - 1s - loss: 0.0107 - acc: 0.5228 - mean_absolute_error: 0.0809 - mean_squared_error: 0.0107 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0557 - val_mean_squared_error: 0.0056
Epoch 8/30
1712/1712 [==============================] - 1s - loss: 0.0102 - acc: 0.5426 - mean_absolute_error: 0.0788 - mean_squared_error: 0.0102 - val_loss: 0.0052 - val_acc: 0.6963 - val_mean_absolute_error: 0.0533 - val_mean_squared_error: 0.0052
Epoch 9/30
1712/1712 [==============================] - 1s - loss: 0.0097 - acc: 0.5438 - mean_absolute_error: 0.0768 - mean_squared_error: 0.0097 - val_loss: 0.0053 - val_acc: 0.6963 - val_mean_absolute_error: 0.0540 - val_mean_squared_error: 0.0053
Epoch 10/30
1712/1712 [==============================] - 1s - loss: 0.0093 - acc: 0.5607 - mean_absolute_error: 0.0751 - mean_squared_error: 0.0093 - val_loss: 0.0053 - val_acc: 0.6963 - val_mean_absolute_error: 0.0537 - val_mean_squared_error: 0.0053
Epoch 11/30
1712/1712 [==============================] - 1s - loss: 0.0089 - acc: 0.5730 - mean_absolute_error: 0.0734 - mean_squared_error: 0.0089 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0520 - val_mean_squared_error: 0.0050
Epoch 12/30
1712/1712 [==============================] - 1s - loss: 0.0085 - acc: 0.5900 - mean_absolute_error: 0.0716 - mean_squared_error: 0.0085 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0500 - val_mean_squared_error: 0.0047
Epoch 13/30
1712/1712 [==============================] - 1s - loss: 0.0084 - acc: 0.5970 - mean_absolute_error: 0.0712 - mean_squared_error: 0.0084 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0504 - val_mean_squared_error: 0.0047
Epoch 14/30
1712/1712 [==============================] - 1s - loss: 0.0081 - acc: 0.5911 - mean_absolute_error: 0.0693 - mean_squared_error: 0.0081 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0523 - val_mean_squared_error: 0.0050
Epoch 15/30
1712/1712 [==============================] - 1s - loss: 0.0079 - acc: 0.5923 - mean_absolute_error: 0.0686 - mean_squared_error: 0.0079 - val_loss: 0.0048 - val_acc: 0.6963 - val_mean_absolute_error: 0.0508 - val_mean_squared_error: 0.0048
Epoch 16/30
1712/1712 [==============================] - 1s - loss: 0.0077 - acc: 0.5900 - mean_absolute_error: 0.0676 - mean_squared_error: 0.0077 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0502 - val_mean_squared_error: 0.0047
Epoch 17/30
1712/1712 [==============================] - 1s - loss: 0.0075 - acc: 0.6011 - mean_absolute_error: 0.0667 - mean_squared_error: 0.0075 - val_loss: 0.0045 - val_acc: 0.6963 - val_mean_absolute_error: 0.0492 - val_mean_squared_error: 0.0045
Epoch 18/30
1712/1712 [==============================] - 1s - loss: 0.0073 - acc: 0.6186 - mean_absolute_error: 0.0658 - mean_squared_error: 0.0073 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0516 - val_mean_squared_error: 0.0049
Epoch 19/30
1712/1712 [==============================] - 1s - loss: 0.0072 - acc: 0.6133 - mean_absolute_error: 0.0649 - mean_squared_error: 0.0072 - val_loss: 0.0045 - val_acc: 0.6963 - val_mean_absolute_error: 0.0490 - val_mean_squared_error: 0.0045
Epoch 20/30
1712/1712 [==============================] - 1s - loss: 0.0070 - acc: 0.6197 - mean_absolute_error: 0.0642 - mean_squared_error: 0.0070 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0499 - val_mean_squared_error: 0.0046
Epoch 21/30
1712/1712 [==============================] - 1s - loss: 0.0068 - acc: 0.6192 - mean_absolute_error: 0.0632 - mean_squared_error: 0.0068 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0496 - val_mean_squared_error: 0.0046
Epoch 22/30
1712/1712 [==============================] - 1s - loss: 0.0069 - acc: 0.6244 - mean_absolute_error: 0.0633 - mean_squared_error: 0.0069 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0489 - val_mean_squared_error: 0.0044
Epoch 23/30
1712/1712 [==============================] - 1s - loss: 0.0067 - acc: 0.6268 - mean_absolute_error: 0.0622 - mean_squared_error: 0.0067 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0495 - val_mean_squared_error: 0.0046
Epoch 24/30
1712/1712 [==============================] - 1s - loss: 0.0065 - acc: 0.6355 - mean_absolute_error: 0.0617 - mean_squared_error: 0.0065 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0486 - val_mean_squared_error: 0.0044
Epoch 25/30
1712/1712 [==============================] - 1s - loss: 0.0064 - acc: 0.6484 - mean_absolute_error: 0.0612 - mean_squared_error: 0.0064 - val_loss: 0.0045 - val_acc: 0.6963 - val_mean_absolute_error: 0.0490 - val_mean_squared_error: 0.0045
Epoch 26/30
1712/1712 [==============================] - 1s - loss: 0.0064 - acc: 0.6489 - mean_absolute_error: 0.0611 - mean_squared_error: 0.0064 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0488 - val_mean_squared_error: 0.0044
Epoch 27/30
1712/1712 [==============================] - 1s - loss: 0.0063 - acc: 0.6454 - mean_absolute_error: 0.0604 - mean_squared_error: 0.0063 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0495 - val_mean_squared_error: 0.0046
Epoch 28/30
1712/1712 [==============================] - 1s - loss: 0.0063 - acc: 0.6402 - mean_absolute_error: 0.0601 - mean_squared_error: 0.0063 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0499 - val_mean_squared_error: 0.0046
Epoch 29/30
1712/1712 [==============================] - 1s - loss: 0.0061 - acc: 0.6489 - mean_absolute_error: 0.0595 - mean_squared_error: 0.0061 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0485 - val_mean_squared_error: 0.0044
Epoch 30/30
1712/1712 [==============================] - 1s - loss: 0.0060 - acc: 0.6560 - mean_absolute_error: 0.0591 - mean_squared_error: 0.0060 - val_loss: 0.0046 - val_acc: 0.6963 - val_mean_absolute_error: 0.0498 - val_mean_squared_error: 0.0046
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:
# the two look quite similar, but the accuracy looks like its overfitting and not generalizing properly
# lets try making the drop out more progressive

In [45]:
model7 = Sequential()
model7.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model7.add(MaxPooling2D(pool_size=(2, 2)))
model7.add(Dropout(0.1))

model7.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model7.add(MaxPooling2D(pool_size=(2, 2)))
model7.add(Dropout(0.2))

model7.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model7.add(MaxPooling2D(pool_size=(2, 2)))
model7.add(Dropout(0.3))

model7.add(Flatten())
model7.add(Dense(256))
model7.add(Dropout(0.5))
model7.add(Dense(30))

# Summarize the model
model7.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_28 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_28 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_32 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_29 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_29 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_33 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_30 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_30 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_34 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_10 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_24 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_35 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_25 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________

In [46]:
opt = 'Adamax'
epochs = 30
model7.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model7.fit(X_train, y_train, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


Train on 1712 samples, validate on 428 samples
Epoch 1/30
1712/1712 [==============================] - 1s - loss: 0.0900 - acc: 0.2915 - mean_absolute_error: 0.2031 - mean_squared_error: 0.0900 - val_loss: 0.0920 - val_acc: 0.6192 - val_mean_absolute_error: 0.2593 - val_mean_squared_error: 0.0920
Epoch 2/30
1712/1712 [==============================] - 1s - loss: 0.0219 - acc: 0.3966 - mean_absolute_error: 0.1170 - mean_squared_error: 0.0219 - val_loss: 0.0785 - val_acc: 0.6963 - val_mean_absolute_error: 0.2374 - val_mean_squared_error: 0.0785
Epoch 3/30
1712/1712 [==============================] - 1s - loss: 0.0178 - acc: 0.4141 - mean_absolute_error: 0.1056 - mean_squared_error: 0.0178 - val_loss: 0.0619 - val_acc: 0.6963 - val_mean_absolute_error: 0.2079 - val_mean_squared_error: 0.0619
Epoch 4/30
1712/1712 [==============================] - 1s - loss: 0.0156 - acc: 0.4463 - mean_absolute_error: 0.0984 - mean_squared_error: 0.0156 - val_loss: 0.0494 - val_acc: 0.7009 - val_mean_absolute_error: 0.1841 - val_mean_squared_error: 0.0494
Epoch 5/30
1712/1712 [==============================] - 1s - loss: 0.0142 - acc: 0.4714 - mean_absolute_error: 0.0940 - mean_squared_error: 0.0142 - val_loss: 0.0478 - val_acc: 0.6986 - val_mean_absolute_error: 0.1817 - val_mean_squared_error: 0.0478
Epoch 6/30
1712/1712 [==============================] - 1s - loss: 0.0136 - acc: 0.4731 - mean_absolute_error: 0.0918 - mean_squared_error: 0.0136 - val_loss: 0.0415 - val_acc: 0.6986 - val_mean_absolute_error: 0.1675 - val_mean_squared_error: 0.0415
Epoch 7/30
1712/1712 [==============================] - 1s - loss: 0.0127 - acc: 0.4988 - mean_absolute_error: 0.0885 - mean_squared_error: 0.0127 - val_loss: 0.0361 - val_acc: 0.7009 - val_mean_absolute_error: 0.1551 - val_mean_squared_error: 0.0361
Epoch 8/30
1712/1712 [==============================] - 1s - loss: 0.0117 - acc: 0.5041 - mean_absolute_error: 0.0847 - mean_squared_error: 0.0117 - val_loss: 0.0296 - val_acc: 0.7079 - val_mean_absolute_error: 0.1401 - val_mean_squared_error: 0.0296
Epoch 9/30
1712/1712 [==============================] - 1s - loss: 0.0111 - acc: 0.5117 - mean_absolute_error: 0.0825 - mean_squared_error: 0.0111 - val_loss: 0.0273 - val_acc: 0.7103 - val_mean_absolute_error: 0.1333 - val_mean_squared_error: 0.0273
Epoch 10/30
1712/1712 [==============================] - 1s - loss: 0.0104 - acc: 0.5286 - mean_absolute_error: 0.0796 - mean_squared_error: 0.0104 - val_loss: 0.0225 - val_acc: 0.7266 - val_mean_absolute_error: 0.1207 - val_mean_squared_error: 0.0225
Epoch 11/30
1712/1712 [==============================] - 1s - loss: 0.0097 - acc: 0.5421 - mean_absolute_error: 0.0772 - mean_squared_error: 0.0097 - val_loss: 0.0220 - val_acc: 0.7150 - val_mean_absolute_error: 0.1187 - val_mean_squared_error: 0.0220
Epoch 12/30
1712/1712 [==============================] - 1s - loss: 0.0093 - acc: 0.5362 - mean_absolute_error: 0.0752 - mean_squared_error: 0.0093 - val_loss: 0.0210 - val_acc: 0.7220 - val_mean_absolute_error: 0.1154 - val_mean_squared_error: 0.0210
Epoch 13/30
1712/1712 [==============================] - 1s - loss: 0.0089 - acc: 0.5461 - mean_absolute_error: 0.0737 - mean_squared_error: 0.0089 - val_loss: 0.0171 - val_acc: 0.7336 - val_mean_absolute_error: 0.1030 - val_mean_squared_error: 0.0171
Epoch 14/30
1712/1712 [==============================] - 1s - loss: 0.0085 - acc: 0.5730 - mean_absolute_error: 0.0715 - mean_squared_error: 0.0085 - val_loss: 0.0147 - val_acc: 0.7150 - val_mean_absolute_error: 0.0951 - val_mean_squared_error: 0.0147
Epoch 15/30
1712/1712 [==============================] - 1s - loss: 0.0082 - acc: 0.5771 - mean_absolute_error: 0.0703 - mean_squared_error: 0.0082 - val_loss: 0.0147 - val_acc: 0.7243 - val_mean_absolute_error: 0.0948 - val_mean_squared_error: 0.0147
Epoch 16/30
1712/1712 [==============================] - 1s - loss: 0.0076 - acc: 0.5993 - mean_absolute_error: 0.0676 - mean_squared_error: 0.0076 - val_loss: 0.0122 - val_acc: 0.7336 - val_mean_absolute_error: 0.0862 - val_mean_squared_error: 0.0122
Epoch 17/30
1712/1712 [==============================] - 1s - loss: 0.0073 - acc: 0.5771 - mean_absolute_error: 0.0661 - mean_squared_error: 0.0073 - val_loss: 0.0106 - val_acc: 0.7196 - val_mean_absolute_error: 0.0785 - val_mean_squared_error: 0.0106
Epoch 18/30
1712/1712 [==============================] - 1s - loss: 0.0072 - acc: 0.6063 - mean_absolute_error: 0.0657 - mean_squared_error: 0.0072 - val_loss: 0.0112 - val_acc: 0.7407 - val_mean_absolute_error: 0.0814 - val_mean_squared_error: 0.0112
Epoch 19/30
1712/1712 [==============================] - 1s - loss: 0.0069 - acc: 0.6139 - mean_absolute_error: 0.0643 - mean_squared_error: 0.0069 - val_loss: 0.0090 - val_acc: 0.7290 - val_mean_absolute_error: 0.0716 - val_mean_squared_error: 0.0090
Epoch 20/30
1712/1712 [==============================] - 1s - loss: 0.0066 - acc: 0.6232 - mean_absolute_error: 0.0628 - mean_squared_error: 0.0066 - val_loss: 0.0086 - val_acc: 0.7477 - val_mean_absolute_error: 0.0699 - val_mean_squared_error: 0.0086
Epoch 21/30
1712/1712 [==============================] - 1s - loss: 0.0064 - acc: 0.6081 - mean_absolute_error: 0.0618 - mean_squared_error: 0.0064 - val_loss: 0.0068 - val_acc: 0.7266 - val_mean_absolute_error: 0.0615 - val_mean_squared_error: 0.0068
Epoch 22/30
1712/1712 [==============================] - 1s - loss: 0.0061 - acc: 0.6285 - mean_absolute_error: 0.0601 - mean_squared_error: 0.0061 - val_loss: 0.0059 - val_acc: 0.7243 - val_mean_absolute_error: 0.0573 - val_mean_squared_error: 0.0059
Epoch 23/30
1712/1712 [==============================] - 1s - loss: 0.0058 - acc: 0.6332 - mean_absolute_error: 0.0588 - mean_squared_error: 0.0058 - val_loss: 0.0071 - val_acc: 0.7220 - val_mean_absolute_error: 0.0633 - val_mean_squared_error: 0.0071
Epoch 24/30
1712/1712 [==============================] - 1s - loss: 0.0058 - acc: 0.6320 - mean_absolute_error: 0.0587 - mean_squared_error: 0.0058 - val_loss: 0.0039 - val_acc: 0.7243 - val_mean_absolute_error: 0.0456 - val_mean_squared_error: 0.0039
Epoch 25/30
1712/1712 [==============================] - 1s - loss: 0.0055 - acc: 0.6268 - mean_absolute_error: 0.0573 - mean_squared_error: 0.0055 - val_loss: 0.0039 - val_acc: 0.7220 - val_mean_absolute_error: 0.0456 - val_mean_squared_error: 0.0039
Epoch 26/30
1712/1712 [==============================] - 1s - loss: 0.0053 - acc: 0.6431 - mean_absolute_error: 0.0563 - mean_squared_error: 0.0053 - val_loss: 0.0044 - val_acc: 0.7290 - val_mean_absolute_error: 0.0487 - val_mean_squared_error: 0.0044
Epoch 27/30
1712/1712 [==============================] - 1s - loss: 0.0052 - acc: 0.6384 - mean_absolute_error: 0.0554 - mean_squared_error: 0.0052 - val_loss: 0.0042 - val_acc: 0.7079 - val_mean_absolute_error: 0.0473 - val_mean_squared_error: 0.0042
Epoch 28/30
1712/1712 [==============================] - 1s - loss: 0.0051 - acc: 0.6682 - mean_absolute_error: 0.0546 - mean_squared_error: 0.0051 - val_loss: 0.0036 - val_acc: 0.7196 - val_mean_absolute_error: 0.0434 - val_mean_squared_error: 0.0036
Epoch 29/30
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6647 - mean_absolute_error: 0.0541 - mean_squared_error: 0.0050 - val_loss: 0.0032 - val_acc: 0.7079 - val_mean_absolute_error: 0.0411 - val_mean_squared_error: 0.0032
Epoch 30/30
1712/1712 [==============================] - 1s - loss: 0.0047 - acc: 0.6519 - mean_absolute_error: 0.0523 - mean_squared_error: 0.0047 - val_loss: 0.0034 - val_acc: 0.7196 - val_mean_absolute_error: 0.0422 - val_mean_squared_error: 0.0034
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:
# better, also looks like we could try relu activation on the hidden fully connected layer

In [47]:
model8 = Sequential()
model8.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model8.add(MaxPooling2D(pool_size=(2, 2)))
model8.add(Dropout(0.1))

model8.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model8.add(MaxPooling2D(pool_size=(2, 2)))
model8.add(Dropout(0.2))

model8.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model8.add(MaxPooling2D(pool_size=(2, 2)))
model8.add(Dropout(0.3))

model8.add(Flatten())
model8.add(Dense(256, activation='relu'))
model8.add(Dropout(0.5))
model8.add(Dense(30))

# Summarize the model
model8.summary()

opt = 'Adamax'
epochs = 30
model8.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model8.fit(X_train, y_train, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_31 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_31 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_36 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_32 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_32 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_37 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_33 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_33 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_38 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_11 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_26 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_39 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_27 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 1712 samples, validate on 428 samples
Epoch 1/30
1712/1712 [==============================] - 1s - loss: 0.0503 - acc: 0.2786 - mean_absolute_error: 0.1717 - mean_squared_error: 0.0503 - val_loss: 0.0646 - val_acc: 0.6893 - val_mean_absolute_error: 0.2136 - val_mean_squared_error: 0.0646
Epoch 2/30
1712/1712 [==============================] - 1s - loss: 0.0204 - acc: 0.3487 - mean_absolute_error: 0.1117 - mean_squared_error: 0.0204 - val_loss: 0.0473 - val_acc: 0.6963 - val_mean_absolute_error: 0.1800 - val_mean_squared_error: 0.0473
Epoch 3/30
1712/1712 [==============================] - 1s - loss: 0.0158 - acc: 0.3838 - mean_absolute_error: 0.0978 - mean_squared_error: 0.0158 - val_loss: 0.0368 - val_acc: 0.6963 - val_mean_absolute_error: 0.1574 - val_mean_squared_error: 0.0368
Epoch 4/30
1712/1712 [==============================] - 1s - loss: 0.0140 - acc: 0.4299 - mean_absolute_error: 0.0916 - mean_squared_error: 0.0140 - val_loss: 0.0311 - val_acc: 0.6963 - val_mean_absolute_error: 0.1441 - val_mean_squared_error: 0.0311
Epoch 5/30
1712/1712 [==============================] - 1s - loss: 0.0124 - acc: 0.4638 - mean_absolute_error: 0.0861 - mean_squared_error: 0.0124 - val_loss: 0.0245 - val_acc: 0.6963 - val_mean_absolute_error: 0.1269 - val_mean_squared_error: 0.0245
Epoch 6/30
1712/1712 [==============================] - 1s - loss: 0.0111 - acc: 0.4907 - mean_absolute_error: 0.0810 - mean_squared_error: 0.0111 - val_loss: 0.0186 - val_acc: 0.6963 - val_mean_absolute_error: 0.1092 - val_mean_squared_error: 0.0186
Epoch 7/30
1712/1712 [==============================] - 1s - loss: 0.0104 - acc: 0.5275 - mean_absolute_error: 0.0781 - mean_squared_error: 0.0104 - val_loss: 0.0145 - val_acc: 0.6963 - val_mean_absolute_error: 0.0952 - val_mean_squared_error: 0.0145
Epoch 8/30
1712/1712 [==============================] - 1s - loss: 0.0098 - acc: 0.5607 - mean_absolute_error: 0.0755 - mean_squared_error: 0.0098 - val_loss: 0.0171 - val_acc: 0.6963 - val_mean_absolute_error: 0.1041 - val_mean_squared_error: 0.0171
Epoch 9/30
1712/1712 [==============================] - 1s - loss: 0.0090 - acc: 0.5537 - mean_absolute_error: 0.0725 - mean_squared_error: 0.0090 - val_loss: 0.0101 - val_acc: 0.6963 - val_mean_absolute_error: 0.0776 - val_mean_squared_error: 0.0101
Epoch 10/30
1712/1712 [==============================] - 1s - loss: 0.0086 - acc: 0.5794 - mean_absolute_error: 0.0706 - mean_squared_error: 0.0086 - val_loss: 0.0095 - val_acc: 0.6963 - val_mean_absolute_error: 0.0748 - val_mean_squared_error: 0.0095
Epoch 11/30
1712/1712 [==============================] - 1s - loss: 0.0083 - acc: 0.5981 - mean_absolute_error: 0.0691 - mean_squared_error: 0.0083 - val_loss: 0.0098 - val_acc: 0.6963 - val_mean_absolute_error: 0.0764 - val_mean_squared_error: 0.0098
Epoch 12/30
1712/1712 [==============================] - 1s - loss: 0.0080 - acc: 0.6180 - mean_absolute_error: 0.0680 - mean_squared_error: 0.0080 - val_loss: 0.0069 - val_acc: 0.6963 - val_mean_absolute_error: 0.0620 - val_mean_squared_error: 0.0069
Epoch 13/30
1712/1712 [==============================] - 1s - loss: 0.0078 - acc: 0.6022 - mean_absolute_error: 0.0669 - mean_squared_error: 0.0078 - val_loss: 0.0080 - val_acc: 0.6963 - val_mean_absolute_error: 0.0677 - val_mean_squared_error: 0.0080
Epoch 14/30
1712/1712 [==============================] - 1s - loss: 0.0075 - acc: 0.6320 - mean_absolute_error: 0.0655 - mean_squared_error: 0.0075 - val_loss: 0.0067 - val_acc: 0.6963 - val_mean_absolute_error: 0.0615 - val_mean_squared_error: 0.0067
Epoch 15/30
1712/1712 [==============================] - 1s - loss: 0.0072 - acc: 0.6162 - mean_absolute_error: 0.0641 - mean_squared_error: 0.0072 - val_loss: 0.0068 - val_acc: 0.6963 - val_mean_absolute_error: 0.0619 - val_mean_squared_error: 0.0068
Epoch 16/30
1712/1712 [==============================] - 1s - loss: 0.0070 - acc: 0.6384 - mean_absolute_error: 0.0632 - mean_squared_error: 0.0070 - val_loss: 0.0065 - val_acc: 0.6963 - val_mean_absolute_error: 0.0605 - val_mean_squared_error: 0.0065
Epoch 17/30
1712/1712 [==============================] - 1s - loss: 0.0068 - acc: 0.6338 - mean_absolute_error: 0.0622 - mean_squared_error: 0.0068 - val_loss: 0.0059 - val_acc: 0.6963 - val_mean_absolute_error: 0.0571 - val_mean_squared_error: 0.0059
Epoch 18/30
1712/1712 [==============================] - 1s - loss: 0.0066 - acc: 0.6595 - mean_absolute_error: 0.0613 - mean_squared_error: 0.0066 - val_loss: 0.0060 - val_acc: 0.6963 - val_mean_absolute_error: 0.0579 - val_mean_squared_error: 0.0060
Epoch 19/30
1712/1712 [==============================] - 1s - loss: 0.0064 - acc: 0.6583 - mean_absolute_error: 0.0601 - mean_squared_error: 0.0064 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0514 - val_mean_squared_error: 0.0049
Epoch 20/30
1712/1712 [==============================] - 1s - loss: 0.0062 - acc: 0.6606 - mean_absolute_error: 0.0593 - mean_squared_error: 0.0062 - val_loss: 0.0052 - val_acc: 0.6963 - val_mean_absolute_error: 0.0535 - val_mean_squared_error: 0.0052
Epoch 21/30
1712/1712 [==============================] - 1s - loss: 0.0061 - acc: 0.6682 - mean_absolute_error: 0.0586 - mean_squared_error: 0.0061 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0521 - val_mean_squared_error: 0.0049
Epoch 22/30
1712/1712 [==============================] - 1s - loss: 0.0059 - acc: 0.6758 - mean_absolute_error: 0.0577 - mean_squared_error: 0.0059 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0504 - val_mean_squared_error: 0.0047
Epoch 23/30
1712/1712 [==============================] - 1s - loss: 0.0056 - acc: 0.6893 - mean_absolute_error: 0.0563 - mean_squared_error: 0.0056 - val_loss: 0.0044 - val_acc: 0.6963 - val_mean_absolute_error: 0.0485 - val_mean_squared_error: 0.0044
Epoch 24/30
1712/1712 [==============================] - 1s - loss: 0.0054 - acc: 0.6787 - mean_absolute_error: 0.0555 - mean_squared_error: 0.0054 - val_loss: 0.0045 - val_acc: 0.6963 - val_mean_absolute_error: 0.0493 - val_mean_squared_error: 0.0045
Epoch 25/30
1712/1712 [==============================] - 1s - loss: 0.0054 - acc: 0.6741 - mean_absolute_error: 0.0547 - mean_squared_error: 0.0054 - val_loss: 0.0041 - val_acc: 0.6963 - val_mean_absolute_error: 0.0467 - val_mean_squared_error: 0.0041
Epoch 26/30
1712/1712 [==============================] - 1s - loss: 0.0052 - acc: 0.6875 - mean_absolute_error: 0.0543 - mean_squared_error: 0.0052 - val_loss: 0.0041 - val_acc: 0.6963 - val_mean_absolute_error: 0.0473 - val_mean_squared_error: 0.0041
Epoch 27/30
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6904 - mean_absolute_error: 0.0532 - mean_squared_error: 0.0050 - val_loss: 0.0040 - val_acc: 0.6963 - val_mean_absolute_error: 0.0463 - val_mean_squared_error: 0.0040
Epoch 28/30
1712/1712 [==============================] - 1s - loss: 0.0049 - acc: 0.6758 - mean_absolute_error: 0.0522 - mean_squared_error: 0.0049 - val_loss: 0.0035 - val_acc: 0.6963 - val_mean_absolute_error: 0.0432 - val_mean_squared_error: 0.0035
Epoch 29/30
1712/1712 [==============================] - 1s - loss: 0.0046 - acc: 0.7021 - mean_absolute_error: 0.0506 - mean_squared_error: 0.0046 - val_loss: 0.0036 - val_acc: 0.6963 - val_mean_absolute_error: 0.0439 - val_mean_squared_error: 0.0036
Epoch 30/30
1712/1712 [==============================] - 1s - loss: 0.0046 - acc: 0.6951 - mean_absolute_error: 0.0505 - mean_squared_error: 0.0046 - val_loss: 0.0033 - val_acc: 0.6963 - val_mean_absolute_error: 0.0420 - val_mean_squared_error: 0.0033
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:


In [48]:
# lets add more data with data augmentation by horizontally flipping all the images and labels

In [49]:
X_train.shape


Out[49]:
(2140, 96, 96, 1)

In [50]:
X_train_flipped = np.flip(np.copy(X_train), axis=2)

In [51]:
fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(9):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    plot_data(X_train_flipped[i], y_train[i], ax)



In [52]:
y_train.shape


Out[52]:
(2140, 30)

In [53]:
# now we need to flip the x values which are even indexes
flipped_indices = [
    (0, 2), (1, 3),
    (4, 8), (5, 9), (6, 10), (7, 11),
    (12, 16), (13, 17), (14, 18), (15, 19),
    (22, 24), (23, 25)
]

y_train_flipped = np.copy(y_train)

points = y_train_flipped.shape[1]
for i in range(len(y_train_flipped)):
    for x in range(0, points, 2):
        y_train_flipped[i][x] *= -1
        
    for (a, b) in flipped_indices:
        y_train_flipped[i][a], y_train_flipped[i][b] = y_train_flipped[i][b], y_train_flipped[i][a]

In [54]:
fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(9):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    plot_data(X_train_flipped[i], y_train_flipped[i], ax)



In [55]:
#combine data sets

In [56]:
X_train_all = np.concatenate((X_train, X_train_flipped), axis=0)
y_train_all = np.concatenate((y_train, y_train_flipped), axis=0)
# from sklearn.utils import shuffle
# X_train_all, y_train_all = shuffle(X_train_all, y_train_all, random_state=42)

In [57]:
# make sure we didn't stuff anything up
fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(9):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    plot_data(X_train_all[i], y_train_all[i], ax)



In [285]:
X_train_all.shape


Out[285]:
(4280, 96, 96, 1)

In [58]:
model9 = Sequential()
model9.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model9.add(MaxPooling2D(pool_size=(2, 2)))
model9.add(Dropout(0.1))

model9.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model9.add(MaxPooling2D(pool_size=(2, 2)))
model9.add(Dropout(0.2))

model9.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model9.add(MaxPooling2D(pool_size=(2, 2)))
model9.add(Dropout(0.3))

model9.add(Flatten())
model9.add(Dense(256, activation='relu'))
model9.add(Dropout(0.5))
model9.add(Dense(30))

# Summarize the model
model9.summary()

opt = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
epochs = 50
model9.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model9.fit(X_train, y_train, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_34 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_34 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_40 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_35 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_35 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_41 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_36 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_36 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_42 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_12 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_28 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_43 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_29 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 1712 samples, validate on 428 samples
Epoch 1/50
1712/1712 [==============================] - 1s - loss: 0.0544 - acc: 0.3505 - mean_absolute_error: 0.1815 - mean_squared_error: 0.0544 - val_loss: 0.0409 - val_acc: 0.6963 - val_mean_absolute_error: 0.1711 - val_mean_squared_error: 0.0409
Epoch 2/50
1712/1712 [==============================] - 1s - loss: 0.0235 - acc: 0.4019 - mean_absolute_error: 0.1217 - mean_squared_error: 0.0235 - val_loss: 0.0258 - val_acc: 0.6963 - val_mean_absolute_error: 0.1338 - val_mean_squared_error: 0.0258
Epoch 3/50
1712/1712 [==============================] - 1s - loss: 0.0181 - acc: 0.4206 - mean_absolute_error: 0.1061 - mean_squared_error: 0.0181 - val_loss: 0.0203 - val_acc: 0.6963 - val_mean_absolute_error: 0.1165 - val_mean_squared_error: 0.0203
Epoch 4/50
1712/1712 [==============================] - 1s - loss: 0.0152 - acc: 0.4702 - mean_absolute_error: 0.0972 - mean_squared_error: 0.0152 - val_loss: 0.0167 - val_acc: 0.6963 - val_mean_absolute_error: 0.1042 - val_mean_squared_error: 0.0167
Epoch 5/50
1712/1712 [==============================] - 1s - loss: 0.0138 - acc: 0.5093 - mean_absolute_error: 0.0922 - mean_squared_error: 0.0138 - val_loss: 0.0140 - val_acc: 0.6963 - val_mean_absolute_error: 0.0943 - val_mean_squared_error: 0.0140
Epoch 6/50
1712/1712 [==============================] - 1s - loss: 0.0126 - acc: 0.5088 - mean_absolute_error: 0.0878 - mean_squared_error: 0.0126 - val_loss: 0.0150 - val_acc: 0.6963 - val_mean_absolute_error: 0.0977 - val_mean_squared_error: 0.0150
Epoch 7/50
1712/1712 [==============================] - 1s - loss: 0.0115 - acc: 0.5152 - mean_absolute_error: 0.0840 - mean_squared_error: 0.0115 - val_loss: 0.0120 - val_acc: 0.6963 - val_mean_absolute_error: 0.0862 - val_mean_squared_error: 0.0120
Epoch 8/50
1712/1712 [==============================] - 1s - loss: 0.0108 - acc: 0.5210 - mean_absolute_error: 0.0811 - mean_squared_error: 0.0108 - val_loss: 0.0118 - val_acc: 0.6963 - val_mean_absolute_error: 0.0852 - val_mean_squared_error: 0.0118
Epoch 9/50
1712/1712 [==============================] - 1s - loss: 0.0103 - acc: 0.5175 - mean_absolute_error: 0.0790 - mean_squared_error: 0.0103 - val_loss: 0.0109 - val_acc: 0.6963 - val_mean_absolute_error: 0.0815 - val_mean_squared_error: 0.0109
Epoch 10/50
1712/1712 [==============================] - 1s - loss: 0.0096 - acc: 0.5532 - mean_absolute_error: 0.0764 - mean_squared_error: 0.0096 - val_loss: 0.0096 - val_acc: 0.6963 - val_mean_absolute_error: 0.0757 - val_mean_squared_error: 0.0096
Epoch 11/50
1712/1712 [==============================] - 1s - loss: 0.0093 - acc: 0.5718 - mean_absolute_error: 0.0748 - mean_squared_error: 0.0093 - val_loss: 0.0100 - val_acc: 0.6963 - val_mean_absolute_error: 0.0778 - val_mean_squared_error: 0.0100
Epoch 12/50
1712/1712 [==============================] - 1s - loss: 0.0087 - acc: 0.5672 - mean_absolute_error: 0.0725 - mean_squared_error: 0.0087 - val_loss: 0.0094 - val_acc: 0.6963 - val_mean_absolute_error: 0.0747 - val_mean_squared_error: 0.0094
Epoch 13/50
1712/1712 [==============================] - 1s - loss: 0.0084 - acc: 0.5859 - mean_absolute_error: 0.0710 - mean_squared_error: 0.0084 - val_loss: 0.0094 - val_acc: 0.6963 - val_mean_absolute_error: 0.0750 - val_mean_squared_error: 0.0094
Epoch 14/50
1712/1712 [==============================] - 1s - loss: 0.0082 - acc: 0.6057 - mean_absolute_error: 0.0697 - mean_squared_error: 0.0082 - val_loss: 0.0081 - val_acc: 0.6963 - val_mean_absolute_error: 0.0688 - val_mean_squared_error: 0.0081
Epoch 15/50
1712/1712 [==============================] - 1s - loss: 0.0078 - acc: 0.6151 - mean_absolute_error: 0.0679 - mean_squared_error: 0.0078 - val_loss: 0.0085 - val_acc: 0.6963 - val_mean_absolute_error: 0.0707 - val_mean_squared_error: 0.0085
Epoch 16/50
1712/1712 [==============================] - 1s - loss: 0.0077 - acc: 0.6092 - mean_absolute_error: 0.0676 - mean_squared_error: 0.0077 - val_loss: 0.0081 - val_acc: 0.6963 - val_mean_absolute_error: 0.0691 - val_mean_squared_error: 0.0081
Epoch 17/50
1712/1712 [==============================] - 1s - loss: 0.0074 - acc: 0.6232 - mean_absolute_error: 0.0662 - mean_squared_error: 0.0074 - val_loss: 0.0083 - val_acc: 0.6963 - val_mean_absolute_error: 0.0698 - val_mean_squared_error: 0.0083
Epoch 18/50
1712/1712 [==============================] - 1s - loss: 0.0072 - acc: 0.6227 - mean_absolute_error: 0.0649 - mean_squared_error: 0.0072 - val_loss: 0.0067 - val_acc: 0.6963 - val_mean_absolute_error: 0.0618 - val_mean_squared_error: 0.0067
Epoch 19/50
1712/1712 [==============================] - 1s - loss: 0.0071 - acc: 0.6338 - mean_absolute_error: 0.0644 - mean_squared_error: 0.0071 - val_loss: 0.0070 - val_acc: 0.6963 - val_mean_absolute_error: 0.0630 - val_mean_squared_error: 0.0070
Epoch 20/50
1712/1712 [==============================] - 1s - loss: 0.0069 - acc: 0.6273 - mean_absolute_error: 0.0634 - mean_squared_error: 0.0069 - val_loss: 0.0073 - val_acc: 0.6963 - val_mean_absolute_error: 0.0646 - val_mean_squared_error: 0.0073
Epoch 21/50
1712/1712 [==============================] - 1s - loss: 0.0067 - acc: 0.6437 - mean_absolute_error: 0.0624 - mean_squared_error: 0.0067 - val_loss: 0.0065 - val_acc: 0.6963 - val_mean_absolute_error: 0.0602 - val_mean_squared_error: 0.0065
Epoch 22/50
1712/1712 [==============================] - 1s - loss: 0.0066 - acc: 0.6641 - mean_absolute_error: 0.0617 - mean_squared_error: 0.0066 - val_loss: 0.0068 - val_acc: 0.6963 - val_mean_absolute_error: 0.0621 - val_mean_squared_error: 0.0068
Epoch 23/50
1712/1712 [==============================] - 1s - loss: 0.0065 - acc: 0.6443 - mean_absolute_error: 0.0612 - mean_squared_error: 0.0065 - val_loss: 0.0060 - val_acc: 0.6963 - val_mean_absolute_error: 0.0575 - val_mean_squared_error: 0.0060
Epoch 24/50
1712/1712 [==============================] - 1s - loss: 0.0064 - acc: 0.6548 - mean_absolute_error: 0.0606 - mean_squared_error: 0.0064 - val_loss: 0.0062 - val_acc: 0.6963 - val_mean_absolute_error: 0.0586 - val_mean_squared_error: 0.0062
Epoch 25/50
1712/1712 [==============================] - 1s - loss: 0.0063 - acc: 0.6273 - mean_absolute_error: 0.0599 - mean_squared_error: 0.0063 - val_loss: 0.0064 - val_acc: 0.6963 - val_mean_absolute_error: 0.0600 - val_mean_squared_error: 0.0064
Epoch 26/50
1712/1712 [==============================] - 1s - loss: 0.0061 - acc: 0.6606 - mean_absolute_error: 0.0592 - mean_squared_error: 0.0061 - val_loss: 0.0064 - val_acc: 0.6963 - val_mean_absolute_error: 0.0598 - val_mean_squared_error: 0.0064
Epoch 27/50
1712/1712 [==============================] - 1s - loss: 0.0060 - acc: 0.6711 - mean_absolute_error: 0.0587 - mean_squared_error: 0.0060 - val_loss: 0.0061 - val_acc: 0.6963 - val_mean_absolute_error: 0.0582 - val_mean_squared_error: 0.0061
Epoch 28/50
1712/1712 [==============================] - 1s - loss: 0.0059 - acc: 0.6600 - mean_absolute_error: 0.0578 - mean_squared_error: 0.0059 - val_loss: 0.0058 - val_acc: 0.6963 - val_mean_absolute_error: 0.0563 - val_mean_squared_error: 0.0058
Epoch 29/50
1712/1712 [==============================] - 1s - loss: 0.0058 - acc: 0.6676 - mean_absolute_error: 0.0576 - mean_squared_error: 0.0058 - val_loss: 0.0058 - val_acc: 0.6963 - val_mean_absolute_error: 0.0563 - val_mean_squared_error: 0.0058
Epoch 30/50
1712/1712 [==============================] - 1s - loss: 0.0058 - acc: 0.6665 - mean_absolute_error: 0.0572 - mean_squared_error: 0.0058 - val_loss: 0.0057 - val_acc: 0.6963 - val_mean_absolute_error: 0.0561 - val_mean_squared_error: 0.0057
Epoch 31/50
1712/1712 [==============================] - 1s - loss: 0.0057 - acc: 0.6782 - mean_absolute_error: 0.0565 - mean_squared_error: 0.0057 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0553 - val_mean_squared_error: 0.0056
Epoch 32/50
1712/1712 [==============================] - 1s - loss: 0.0056 - acc: 0.6764 - mean_absolute_error: 0.0563 - mean_squared_error: 0.0056 - val_loss: 0.0059 - val_acc: 0.6963 - val_mean_absolute_error: 0.0573 - val_mean_squared_error: 0.0059
Epoch 33/50
1712/1712 [==============================] - 1s - loss: 0.0056 - acc: 0.6904 - mean_absolute_error: 0.0562 - mean_squared_error: 0.0056 - val_loss: 0.0055 - val_acc: 0.6963 - val_mean_absolute_error: 0.0546 - val_mean_squared_error: 0.0055
Epoch 34/50
1712/1712 [==============================] - 1s - loss: 0.0055 - acc: 0.6857 - mean_absolute_error: 0.0559 - mean_squared_error: 0.0055 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0554 - val_mean_squared_error: 0.0056
Epoch 35/50
1712/1712 [==============================] - 1s - loss: 0.0055 - acc: 0.6828 - mean_absolute_error: 0.0555 - mean_squared_error: 0.0055 - val_loss: 0.0054 - val_acc: 0.6963 - val_mean_absolute_error: 0.0541 - val_mean_squared_error: 0.0054
Epoch 36/50
1712/1712 [==============================] - 1s - loss: 0.0054 - acc: 0.6857 - mean_absolute_error: 0.0549 - mean_squared_error: 0.0054 - val_loss: 0.0056 - val_acc: 0.6963 - val_mean_absolute_error: 0.0554 - val_mean_squared_error: 0.0056
Epoch 37/50
1712/1712 [==============================] - 1s - loss: 0.0054 - acc: 0.6980 - mean_absolute_error: 0.0548 - mean_squared_error: 0.0054 - val_loss: 0.0055 - val_acc: 0.6963 - val_mean_absolute_error: 0.0550 - val_mean_squared_error: 0.0055
Epoch 38/50
1712/1712 [==============================] - 1s - loss: 0.0053 - acc: 0.6863 - mean_absolute_error: 0.0542 - mean_squared_error: 0.0053 - val_loss: 0.0054 - val_acc: 0.6963 - val_mean_absolute_error: 0.0545 - val_mean_squared_error: 0.0054
Epoch 39/50
1712/1712 [==============================] - 1s - loss: 0.0053 - acc: 0.6887 - mean_absolute_error: 0.0542 - mean_squared_error: 0.0053 - val_loss: 0.0054 - val_acc: 0.6963 - val_mean_absolute_error: 0.0544 - val_mean_squared_error: 0.0054
Epoch 40/50
1712/1712 [==============================] - 1s - loss: 0.0052 - acc: 0.6998 - mean_absolute_error: 0.0536 - mean_squared_error: 0.0052 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0522 - val_mean_squared_error: 0.0050
Epoch 41/50
1712/1712 [==============================] - 1s - loss: 0.0052 - acc: 0.6951 - mean_absolute_error: 0.0535 - mean_squared_error: 0.0052 - val_loss: 0.0051 - val_acc: 0.6963 - val_mean_absolute_error: 0.0524 - val_mean_squared_error: 0.0051
Epoch 42/50
1712/1712 [==============================] - 1s - loss: 0.0051 - acc: 0.6939 - mean_absolute_error: 0.0533 - mean_squared_error: 0.0051 - val_loss: 0.0051 - val_acc: 0.6963 - val_mean_absolute_error: 0.0525 - val_mean_squared_error: 0.0051
Epoch 43/50
1712/1712 [==============================] - 1s - loss: 0.0051 - acc: 0.6916 - mean_absolute_error: 0.0531 - mean_squared_error: 0.0051 - val_loss: 0.0051 - val_acc: 0.6963 - val_mean_absolute_error: 0.0526 - val_mean_squared_error: 0.0051
Epoch 44/50
1712/1712 [==============================] - 1s - loss: 0.0051 - acc: 0.6933 - mean_absolute_error: 0.0529 - mean_squared_error: 0.0051 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0515 - val_mean_squared_error: 0.0049
Epoch 45/50
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6998 - mean_absolute_error: 0.0524 - mean_squared_error: 0.0050 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0519 - val_mean_squared_error: 0.0050
Epoch 46/50
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.7004 - mean_absolute_error: 0.0525 - mean_squared_error: 0.0050 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0520 - val_mean_squared_error: 0.0050
Epoch 47/50
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6974 - mean_absolute_error: 0.0526 - mean_squared_error: 0.0050 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0512 - val_mean_squared_error: 0.0049
Epoch 48/50
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6974 - mean_absolute_error: 0.0522 - mean_squared_error: 0.0050 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0502 - val_mean_squared_error: 0.0047
Epoch 49/50
1712/1712 [==============================] - 1s - loss: 0.0049 - acc: 0.7062 - mean_absolute_error: 0.0520 - mean_squared_error: 0.0049 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0501 - val_mean_squared_error: 0.0047
Epoch 50/50
1712/1712 [==============================] - 1s - loss: 0.0049 - acc: 0.7027 - mean_absolute_error: 0.0517 - mean_squared_error: 0.0049 - val_loss: 0.0047 - val_acc: 0.6963 - val_mean_absolute_error: 0.0501 - val_mean_squared_error: 0.0047
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:


In [59]:
model10 = Sequential()
model10.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model10.add(MaxPooling2D(pool_size=(2, 2)))
model10.add(Dropout(0.1))

model10.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model10.add(MaxPooling2D(pool_size=(2, 2)))
model10.add(Dropout(0.2))

model10.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model10.add(MaxPooling2D(pool_size=(2, 2)))
model10.add(Dropout(0.3))

model10.add(Flatten())
model10.add(Dense(256, activation='relu'))
model10.add(Dropout(0.5))
model10.add(Dense(30))

# Summarize the model
model10.summary()

opt = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
epochs = 50
model10.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model10.fit(X_train_all, y_train_all, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_37 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_37 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_44 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_38 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_38 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_45 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_39 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_39 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_46 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_13 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_30 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_47 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_31 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 3424 samples, validate on 856 samples
Epoch 1/50
3424/3424 [==============================] - 2s - loss: 0.0423 - acc: 0.3166 - mean_absolute_error: 0.1563 - mean_squared_error: 0.0423 - val_loss: 0.0306 - val_acc: 0.6612 - val_mean_absolute_error: 0.1460 - val_mean_squared_error: 0.0306
Epoch 2/50
3424/3424 [==============================] - 2s - loss: 0.0173 - acc: 0.4337 - mean_absolute_error: 0.1038 - mean_squared_error: 0.0173 - val_loss: 0.0176 - val_acc: 0.6600 - val_mean_absolute_error: 0.1072 - val_mean_squared_error: 0.0176
Epoch 3/50
3424/3424 [==============================] - 2s - loss: 0.0133 - acc: 0.4904 - mean_absolute_error: 0.0908 - mean_squared_error: 0.0133 - val_loss: 0.0131 - val_acc: 0.6600 - val_mean_absolute_error: 0.0904 - val_mean_squared_error: 0.0131
Epoch 4/50
3424/3424 [==============================] - 2s - loss: 0.0114 - acc: 0.5350 - mean_absolute_error: 0.0834 - mean_squared_error: 0.0114 - val_loss: 0.0111 - val_acc: 0.6600 - val_mean_absolute_error: 0.0822 - val_mean_squared_error: 0.0111
Epoch 5/50
3424/3424 [==============================] - 2s - loss: 0.0101 - acc: 0.5578 - mean_absolute_error: 0.0784 - mean_squared_error: 0.0101 - val_loss: 0.0086 - val_acc: 0.6600 - val_mean_absolute_error: 0.0710 - val_mean_squared_error: 0.0086
Epoch 6/50
3424/3424 [==============================] - 2s - loss: 0.0091 - acc: 0.5794 - mean_absolute_error: 0.0740 - mean_squared_error: 0.0091 - val_loss: 0.0081 - val_acc: 0.6600 - val_mean_absolute_error: 0.0688 - val_mean_squared_error: 0.0081
Epoch 7/50
3424/3424 [==============================] - 2s - loss: 0.0083 - acc: 0.5876 - mean_absolute_error: 0.0705 - mean_squared_error: 0.0083 - val_loss: 0.0067 - val_acc: 0.6600 - val_mean_absolute_error: 0.0612 - val_mean_squared_error: 0.0067
Epoch 8/50
3424/3424 [==============================] - 2s - loss: 0.0078 - acc: 0.6063 - mean_absolute_error: 0.0680 - mean_squared_error: 0.0078 - val_loss: 0.0065 - val_acc: 0.6600 - val_mean_absolute_error: 0.0605 - val_mean_squared_error: 0.0065
Epoch 9/50
3424/3424 [==============================] - 2s - loss: 0.0073 - acc: 0.6174 - mean_absolute_error: 0.0654 - mean_squared_error: 0.0073 - val_loss: 0.0062 - val_acc: 0.6600 - val_mean_absolute_error: 0.0584 - val_mean_squared_error: 0.0062
Epoch 10/50
3424/3424 [==============================] - 2s - loss: 0.0070 - acc: 0.6244 - mean_absolute_error: 0.0636 - mean_squared_error: 0.0070 - val_loss: 0.0060 - val_acc: 0.6600 - val_mean_absolute_error: 0.0575 - val_mean_squared_error: 0.0060
Epoch 11/50
3424/3424 [==============================] - 2s - loss: 0.0067 - acc: 0.6300 - mean_absolute_error: 0.0621 - mean_squared_error: 0.0067 - val_loss: 0.0058 - val_acc: 0.6600 - val_mean_absolute_error: 0.0566 - val_mean_squared_error: 0.0058
Epoch 12/50
3424/3424 [==============================] - 2s - loss: 0.0065 - acc: 0.6390 - mean_absolute_error: 0.0611 - mean_squared_error: 0.0065 - val_loss: 0.0059 - val_acc: 0.6600 - val_mean_absolute_error: 0.0572 - val_mean_squared_error: 0.0059
Epoch 13/50
3424/3424 [==============================] - 2s - loss: 0.0062 - acc: 0.6554 - mean_absolute_error: 0.0597 - mean_squared_error: 0.0062 - val_loss: 0.0056 - val_acc: 0.6600 - val_mean_absolute_error: 0.0554 - val_mean_squared_error: 0.0056
Epoch 14/50
3424/3424 [==============================] - 2s - loss: 0.0061 - acc: 0.6603 - mean_absolute_error: 0.0586 - mean_squared_error: 0.0061 - val_loss: 0.0052 - val_acc: 0.6600 - val_mean_absolute_error: 0.0530 - val_mean_squared_error: 0.0052
Epoch 15/50
3424/3424 [==============================] - 2s - loss: 0.0058 - acc: 0.6621 - mean_absolute_error: 0.0575 - mean_squared_error: 0.0058 - val_loss: 0.0053 - val_acc: 0.6600 - val_mean_absolute_error: 0.0536 - val_mean_squared_error: 0.0053
Epoch 16/50
3424/3424 [==============================] - 2s - loss: 0.0057 - acc: 0.6641 - mean_absolute_error: 0.0565 - mean_squared_error: 0.0057 - val_loss: 0.0048 - val_acc: 0.6600 - val_mean_absolute_error: 0.0506 - val_mean_squared_error: 0.0048
Epoch 17/50
3424/3424 [==============================] - 2s - loss: 0.0056 - acc: 0.6638 - mean_absolute_error: 0.0563 - mean_squared_error: 0.0056 - val_loss: 0.0051 - val_acc: 0.6600 - val_mean_absolute_error: 0.0524 - val_mean_squared_error: 0.0051
Epoch 18/50
3424/3424 [==============================] - 2s - loss: 0.0055 - acc: 0.6738 - mean_absolute_error: 0.0554 - mean_squared_error: 0.0055 - val_loss: 0.0052 - val_acc: 0.6600 - val_mean_absolute_error: 0.0529 - val_mean_squared_error: 0.0052
Epoch 19/50
3424/3424 [==============================] - 2s - loss: 0.0054 - acc: 0.6744 - mean_absolute_error: 0.0547 - mean_squared_error: 0.0054 - val_loss: 0.0048 - val_acc: 0.6600 - val_mean_absolute_error: 0.0507 - val_mean_squared_error: 0.0048
Epoch 20/50
3424/3424 [==============================] - 2s - loss: 0.0053 - acc: 0.6773 - mean_absolute_error: 0.0542 - mean_squared_error: 0.0053 - val_loss: 0.0052 - val_acc: 0.6600 - val_mean_absolute_error: 0.0529 - val_mean_squared_error: 0.0052
Epoch 21/50
3424/3424 [==============================] - 2s - loss: 0.0052 - acc: 0.6820 - mean_absolute_error: 0.0537 - mean_squared_error: 0.0052 - val_loss: 0.0049 - val_acc: 0.6600 - val_mean_absolute_error: 0.0511 - val_mean_squared_error: 0.0049
Epoch 22/50
3424/3424 [==============================] - 2s - loss: 0.0051 - acc: 0.6808 - mean_absolute_error: 0.0531 - mean_squared_error: 0.0051 - val_loss: 0.0049 - val_acc: 0.6600 - val_mean_absolute_error: 0.0515 - val_mean_squared_error: 0.0049
Epoch 23/50
3424/3424 [==============================] - 2s - loss: 0.0050 - acc: 0.6825 - mean_absolute_error: 0.0525 - mean_squared_error: 0.0050 - val_loss: 0.0047 - val_acc: 0.6600 - val_mean_absolute_error: 0.0504 - val_mean_squared_error: 0.0047
Epoch 24/50
3424/3424 [==============================] - 2s - loss: 0.0050 - acc: 0.6860 - mean_absolute_error: 0.0523 - mean_squared_error: 0.0050 - val_loss: 0.0046 - val_acc: 0.6600 - val_mean_absolute_error: 0.0497 - val_mean_squared_error: 0.0046
Epoch 25/50
3424/3424 [==============================] - 2s - loss: 0.0049 - acc: 0.6825 - mean_absolute_error: 0.0519 - mean_squared_error: 0.0049 - val_loss: 0.0046 - val_acc: 0.6600 - val_mean_absolute_error: 0.0494 - val_mean_squared_error: 0.0046
Epoch 26/50
3424/3424 [==============================] - 2s - loss: 0.0049 - acc: 0.6863 - mean_absolute_error: 0.0517 - mean_squared_error: 0.0049 - val_loss: 0.0046 - val_acc: 0.6600 - val_mean_absolute_error: 0.0497 - val_mean_squared_error: 0.0046
Epoch 27/50
3424/3424 [==============================] - 2s - loss: 0.0049 - acc: 0.6860 - mean_absolute_error: 0.0514 - mean_squared_error: 0.0049 - val_loss: 0.0046 - val_acc: 0.6600 - val_mean_absolute_error: 0.0495 - val_mean_squared_error: 0.0046
Epoch 28/50
3424/3424 [==============================] - 2s - loss: 0.0048 - acc: 0.6837 - mean_absolute_error: 0.0510 - mean_squared_error: 0.0048 - val_loss: 0.0045 - val_acc: 0.6600 - val_mean_absolute_error: 0.0491 - val_mean_squared_error: 0.0045
Epoch 29/50
3424/3424 [==============================] - 2s - loss: 0.0048 - acc: 0.6895 - mean_absolute_error: 0.0508 - mean_squared_error: 0.0048 - val_loss: 0.0046 - val_acc: 0.6600 - val_mean_absolute_error: 0.0494 - val_mean_squared_error: 0.0046
Epoch 30/50
3424/3424 [==============================] - 2s - loss: 0.0047 - acc: 0.6878 - mean_absolute_error: 0.0506 - mean_squared_error: 0.0047 - val_loss: 0.0045 - val_acc: 0.6600 - val_mean_absolute_error: 0.0490 - val_mean_squared_error: 0.0045
Epoch 31/50
3424/3424 [==============================] - 2s - loss: 0.0047 - acc: 0.6875 - mean_absolute_error: 0.0505 - mean_squared_error: 0.0047 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0487 - val_mean_squared_error: 0.0044
Epoch 32/50
3424/3424 [==============================] - 2s - loss: 0.0047 - acc: 0.6878 - mean_absolute_error: 0.0501 - mean_squared_error: 0.0047 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0487 - val_mean_squared_error: 0.0044
Epoch 33/50
3424/3424 [==============================] - 2s - loss: 0.0047 - acc: 0.6881 - mean_absolute_error: 0.0502 - mean_squared_error: 0.0047 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0486 - val_mean_squared_error: 0.0044
Epoch 34/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6881 - mean_absolute_error: 0.0499 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0486 - val_mean_squared_error: 0.0044
Epoch 35/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6887 - mean_absolute_error: 0.0498 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0485 - val_mean_squared_error: 0.0044
Epoch 36/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6884 - mean_absolute_error: 0.0497 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
Epoch 37/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6881 - mean_absolute_error: 0.0496 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0485 - val_mean_squared_error: 0.0044
Epoch 38/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6878 - mean_absolute_error: 0.0494 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
Epoch 39/50
3424/3424 [==============================] - 2s - loss: 0.0046 - acc: 0.6881 - mean_absolute_error: 0.0494 - mean_squared_error: 0.0046 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0483 - val_mean_squared_error: 0.0044
Epoch 40/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6881 - mean_absolute_error: 0.0492 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
Epoch 41/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0491 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0483 - val_mean_squared_error: 0.0044
Epoch 42/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0491 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
Epoch 43/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0490 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0044
Epoch 44/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6887 - mean_absolute_error: 0.0488 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0483 - val_mean_squared_error: 0.0044
Epoch 45/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0488 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0482 - val_mean_squared_error: 0.0044
Epoch 46/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0487 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0483 - val_mean_squared_error: 0.0044
Epoch 47/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6884 - mean_absolute_error: 0.0486 - mean_squared_error: 0.0045 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0483 - val_mean_squared_error: 0.0044
Epoch 48/50
3424/3424 [==============================] - 2s - loss: 0.0044 - acc: 0.6884 - mean_absolute_error: 0.0485 - mean_squared_error: 0.0044 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0482 - val_mean_squared_error: 0.0044
Epoch 49/50
3424/3424 [==============================] - 2s - loss: 0.0044 - acc: 0.6884 - mean_absolute_error: 0.0485 - mean_squared_error: 0.0044 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0482 - val_mean_squared_error: 0.0044
Epoch 50/50
3424/3424 [==============================] - 2s - loss: 0.0044 - acc: 0.6884 - mean_absolute_error: 0.0484 - mean_squared_error: 0.0044 - val_loss: 0.0044 - val_acc: 0.6600 - val_mean_absolute_error: 0.0482 - val_mean_squared_error: 0.0044
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [60]:
model11 = Sequential()
model11.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model11.add(MaxPooling2D(pool_size=(2, 2)))
model11.add(Dropout(0.1))

model11.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model11.add(MaxPooling2D(pool_size=(2, 2)))
model11.add(Dropout(0.2))

model11.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model11.add(MaxPooling2D(pool_size=(2, 2)))
model11.add(Dropout(0.3))

model11.add(Flatten())
model11.add(Dense(256, activation='relu'))
model11.add(Dropout(0.5))
model11.add(Dense(30))

# Summarize the model
model11.summary()

opt = 'Adamax'
epochs = 50
model11.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model11.fit(X_train, y_train, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_40 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_40 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_48 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_41 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_41 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_49 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_42 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_42 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_50 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_14 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_32 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_51 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_33 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 1712 samples, validate on 428 samples
Epoch 1/50
1712/1712 [==============================] - 1s - loss: 0.0467 - acc: 0.3446 - mean_absolute_error: 0.1652 - mean_squared_error: 0.0467 - val_loss: 0.0639 - val_acc: 0.6963 - val_mean_absolute_error: 0.2130 - val_mean_squared_error: 0.0639
Epoch 2/50
1712/1712 [==============================] - 1s - loss: 0.0181 - acc: 0.4381 - mean_absolute_error: 0.1056 - mean_squared_error: 0.0181 - val_loss: 0.0504 - val_acc: 0.6963 - val_mean_absolute_error: 0.1870 - val_mean_squared_error: 0.0504
Epoch 3/50
1712/1712 [==============================] - 1s - loss: 0.0145 - acc: 0.4673 - mean_absolute_error: 0.0941 - mean_squared_error: 0.0145 - val_loss: 0.0541 - val_acc: 0.6963 - val_mean_absolute_error: 0.1939 - val_mean_squared_error: 0.0541
Epoch 4/50
1712/1712 [==============================] - 1s - loss: 0.0128 - acc: 0.5064 - mean_absolute_error: 0.0881 - mean_squared_error: 0.0128 - val_loss: 0.0480 - val_acc: 0.6963 - val_mean_absolute_error: 0.1814 - val_mean_squared_error: 0.0480
Epoch 5/50
1712/1712 [==============================] - 1s - loss: 0.0117 - acc: 0.5526 - mean_absolute_error: 0.0835 - mean_squared_error: 0.0117 - val_loss: 0.0417 - val_acc: 0.6963 - val_mean_absolute_error: 0.1681 - val_mean_squared_error: 0.0417
Epoch 6/50
1712/1712 [==============================] - 1s - loss: 0.0105 - acc: 0.5520 - mean_absolute_error: 0.0791 - mean_squared_error: 0.0105 - val_loss: 0.0358 - val_acc: 0.6963 - val_mean_absolute_error: 0.1550 - val_mean_squared_error: 0.0358
Epoch 7/50
1712/1712 [==============================] - 1s - loss: 0.0098 - acc: 0.5911 - mean_absolute_error: 0.0762 - mean_squared_error: 0.0098 - val_loss: 0.0400 - val_acc: 0.6963 - val_mean_absolute_error: 0.1638 - val_mean_squared_error: 0.0400
Epoch 8/50
1712/1712 [==============================] - 1s - loss: 0.0096 - acc: 0.6022 - mean_absolute_error: 0.0752 - mean_squared_error: 0.0096 - val_loss: 0.0366 - val_acc: 0.6963 - val_mean_absolute_error: 0.1558 - val_mean_squared_error: 0.0366
Epoch 9/50
1712/1712 [==============================] - 1s - loss: 0.0090 - acc: 0.6250 - mean_absolute_error: 0.0727 - mean_squared_error: 0.0090 - val_loss: 0.0311 - val_acc: 0.6963 - val_mean_absolute_error: 0.1432 - val_mean_squared_error: 0.0311
Epoch 10/50
1712/1712 [==============================] - 1s - loss: 0.0087 - acc: 0.6367 - mean_absolute_error: 0.0714 - mean_squared_error: 0.0087 - val_loss: 0.0329 - val_acc: 0.6963 - val_mean_absolute_error: 0.1474 - val_mean_squared_error: 0.0329
Epoch 11/50
1712/1712 [==============================] - 1s - loss: 0.0081 - acc: 0.6221 - mean_absolute_error: 0.0684 - mean_squared_error: 0.0081 - val_loss: 0.0250 - val_acc: 0.6963 - val_mean_absolute_error: 0.1269 - val_mean_squared_error: 0.0250
Epoch 12/50
1712/1712 [==============================] - 1s - loss: 0.0078 - acc: 0.6507 - mean_absolute_error: 0.0671 - mean_squared_error: 0.0078 - val_loss: 0.0209 - val_acc: 0.6963 - val_mean_absolute_error: 0.1149 - val_mean_squared_error: 0.0209
Epoch 13/50
1712/1712 [==============================] - 1s - loss: 0.0076 - acc: 0.6530 - mean_absolute_error: 0.0663 - mean_squared_error: 0.0076 - val_loss: 0.0252 - val_acc: 0.6963 - val_mean_absolute_error: 0.1279 - val_mean_squared_error: 0.0252
Epoch 14/50
1712/1712 [==============================] - 1s - loss: 0.0075 - acc: 0.6530 - mean_absolute_error: 0.0657 - mean_squared_error: 0.0075 - val_loss: 0.0210 - val_acc: 0.6963 - val_mean_absolute_error: 0.1155 - val_mean_squared_error: 0.0210
Epoch 15/50
1712/1712 [==============================] - 1s - loss: 0.0072 - acc: 0.6454 - mean_absolute_error: 0.0643 - mean_squared_error: 0.0072 - val_loss: 0.0189 - val_acc: 0.6963 - val_mean_absolute_error: 0.1085 - val_mean_squared_error: 0.0189
Epoch 16/50
1712/1712 [==============================] - 1s - loss: 0.0068 - acc: 0.6682 - mean_absolute_error: 0.0626 - mean_squared_error: 0.0068 - val_loss: 0.0157 - val_acc: 0.6986 - val_mean_absolute_error: 0.0986 - val_mean_squared_error: 0.0157
Epoch 17/50
1712/1712 [==============================] - 1s - loss: 0.0065 - acc: 0.6764 - mean_absolute_error: 0.0609 - mean_squared_error: 0.0065 - val_loss: 0.0142 - val_acc: 0.6963 - val_mean_absolute_error: 0.0925 - val_mean_squared_error: 0.0142
Epoch 18/50
1712/1712 [==============================] - 1s - loss: 0.0067 - acc: 0.6793 - mean_absolute_error: 0.0619 - mean_squared_error: 0.0067 - val_loss: 0.0138 - val_acc: 0.6963 - val_mean_absolute_error: 0.0919 - val_mean_squared_error: 0.0138
Epoch 19/50
1712/1712 [==============================] - 1s - loss: 0.0062 - acc: 0.6793 - mean_absolute_error: 0.0592 - mean_squared_error: 0.0062 - val_loss: 0.0135 - val_acc: 0.6963 - val_mean_absolute_error: 0.0905 - val_mean_squared_error: 0.0135
Epoch 20/50
1712/1712 [==============================] - 1s - loss: 0.0059 - acc: 0.6834 - mean_absolute_error: 0.0578 - mean_squared_error: 0.0059 - val_loss: 0.0115 - val_acc: 0.6963 - val_mean_absolute_error: 0.0831 - val_mean_squared_error: 0.0115
Epoch 21/50
1712/1712 [==============================] - 1s - loss: 0.0057 - acc: 0.6869 - mean_absolute_error: 0.0567 - mean_squared_error: 0.0057 - val_loss: 0.0089 - val_acc: 0.6963 - val_mean_absolute_error: 0.0722 - val_mean_squared_error: 0.0089
Epoch 22/50
1712/1712 [==============================] - 1s - loss: 0.0055 - acc: 0.6974 - mean_absolute_error: 0.0558 - mean_squared_error: 0.0055 - val_loss: 0.0105 - val_acc: 0.6963 - val_mean_absolute_error: 0.0791 - val_mean_squared_error: 0.0105
Epoch 23/50
1712/1712 [==============================] - 1s - loss: 0.0054 - acc: 0.6910 - mean_absolute_error: 0.0551 - mean_squared_error: 0.0054 - val_loss: 0.0072 - val_acc: 0.6963 - val_mean_absolute_error: 0.0645 - val_mean_squared_error: 0.0072
Epoch 24/50
1712/1712 [==============================] - 1s - loss: 0.0051 - acc: 0.6945 - mean_absolute_error: 0.0536 - mean_squared_error: 0.0051 - val_loss: 0.0074 - val_acc: 0.6963 - val_mean_absolute_error: 0.0646 - val_mean_squared_error: 0.0074
Epoch 25/50
1712/1712 [==============================] - 1s - loss: 0.0050 - acc: 0.6933 - mean_absolute_error: 0.0530 - mean_squared_error: 0.0050 - val_loss: 0.0049 - val_acc: 0.6963 - val_mean_absolute_error: 0.0524 - val_mean_squared_error: 0.0049
Epoch 26/50
1712/1712 [==============================] - 1s - loss: 0.0048 - acc: 0.6910 - mean_absolute_error: 0.0518 - mean_squared_error: 0.0048 - val_loss: 0.0062 - val_acc: 0.6963 - val_mean_absolute_error: 0.0594 - val_mean_squared_error: 0.0062
Epoch 27/50
1712/1712 [==============================] - 1s - loss: 0.0046 - acc: 0.6986 - mean_absolute_error: 0.0507 - mean_squared_error: 0.0046 - val_loss: 0.0050 - val_acc: 0.6963 - val_mean_absolute_error: 0.0525 - val_mean_squared_error: 0.0050
Epoch 28/50
1712/1712 [==============================] - 1s - loss: 0.0044 - acc: 0.7085 - mean_absolute_error: 0.0495 - mean_squared_error: 0.0044 - val_loss: 0.0045 - val_acc: 0.6963 - val_mean_absolute_error: 0.0495 - val_mean_squared_error: 0.0045
Epoch 29/50
1712/1712 [==============================] - 1s - loss: 0.0043 - acc: 0.6986 - mean_absolute_error: 0.0491 - mean_squared_error: 0.0043 - val_loss: 0.0036 - val_acc: 0.6963 - val_mean_absolute_error: 0.0437 - val_mean_squared_error: 0.0036
Epoch 30/50
1712/1712 [==============================] - 1s - loss: 0.0042 - acc: 0.6974 - mean_absolute_error: 0.0483 - mean_squared_error: 0.0042 - val_loss: 0.0030 - val_acc: 0.6963 - val_mean_absolute_error: 0.0395 - val_mean_squared_error: 0.0030
Epoch 31/50
1712/1712 [==============================] - 1s - loss: 0.0040 - acc: 0.7021 - mean_absolute_error: 0.0471 - mean_squared_error: 0.0040 - val_loss: 0.0033 - val_acc: 0.6963 - val_mean_absolute_error: 0.0420 - val_mean_squared_error: 0.0033
Epoch 32/50
1712/1712 [==============================] - 1s - loss: 0.0039 - acc: 0.7039 - mean_absolute_error: 0.0469 - mean_squared_error: 0.0039 - val_loss: 0.0028 - val_acc: 0.6963 - val_mean_absolute_error: 0.0384 - val_mean_squared_error: 0.0028
Epoch 33/50
1712/1712 [==============================] - 1s - loss: 0.0038 - acc: 0.7109 - mean_absolute_error: 0.0456 - mean_squared_error: 0.0038 - val_loss: 0.0031 - val_acc: 0.6963 - val_mean_absolute_error: 0.0409 - val_mean_squared_error: 0.0031
Epoch 34/50
1712/1712 [==============================] - 1s - loss: 0.0038 - acc: 0.6869 - mean_absolute_error: 0.0456 - mean_squared_error: 0.0038 - val_loss: 0.0028 - val_acc: 0.6963 - val_mean_absolute_error: 0.0387 - val_mean_squared_error: 0.0028
Epoch 35/50
1712/1712 [==============================] - 1s - loss: 0.0036 - acc: 0.7085 - mean_absolute_error: 0.0443 - mean_squared_error: 0.0036 - val_loss: 0.0025 - val_acc: 0.7033 - val_mean_absolute_error: 0.0361 - val_mean_squared_error: 0.0025
Epoch 36/50
1712/1712 [==============================] - 1s - loss: 0.0034 - acc: 0.7103 - mean_absolute_error: 0.0434 - mean_squared_error: 0.0034 - val_loss: 0.0023 - val_acc: 0.6986 - val_mean_absolute_error: 0.0347 - val_mean_squared_error: 0.0023
Epoch 37/50
1712/1712 [==============================] - 1s - loss: 0.0034 - acc: 0.7138 - mean_absolute_error: 0.0432 - mean_squared_error: 0.0034 - val_loss: 0.0024 - val_acc: 0.7033 - val_mean_absolute_error: 0.0354 - val_mean_squared_error: 0.0024
Epoch 38/50
1712/1712 [==============================] - 1s - loss: 0.0033 - acc: 0.7173 - mean_absolute_error: 0.0427 - mean_squared_error: 0.0033 - val_loss: 0.0023 - val_acc: 0.7009 - val_mean_absolute_error: 0.0344 - val_mean_squared_error: 0.0023
Epoch 39/50
1712/1712 [==============================] - 1s - loss: 0.0032 - acc: 0.7231 - mean_absolute_error: 0.0416 - mean_squared_error: 0.0032 - val_loss: 0.0024 - val_acc: 0.7009 - val_mean_absolute_error: 0.0352 - val_mean_squared_error: 0.0024
Epoch 40/50
1712/1712 [==============================] - 1s - loss: 0.0032 - acc: 0.7138 - mean_absolute_error: 0.0414 - mean_squared_error: 0.0032 - val_loss: 0.0021 - val_acc: 0.7033 - val_mean_absolute_error: 0.0332 - val_mean_squared_error: 0.0021
Epoch 41/50
1712/1712 [==============================] - 1s - loss: 0.0030 - acc: 0.7079 - mean_absolute_error: 0.0403 - mean_squared_error: 0.0030 - val_loss: 0.0021 - val_acc: 0.7033 - val_mean_absolute_error: 0.0327 - val_mean_squared_error: 0.0021
Epoch 42/50
1712/1712 [==============================] - 1s - loss: 0.0030 - acc: 0.7179 - mean_absolute_error: 0.0400 - mean_squared_error: 0.0030 - val_loss: 0.0021 - val_acc: 0.7033 - val_mean_absolute_error: 0.0331 - val_mean_squared_error: 0.0021
Epoch 43/50
1712/1712 [==============================] - 1s - loss: 0.0028 - acc: 0.7237 - mean_absolute_error: 0.0391 - mean_squared_error: 0.0028 - val_loss: 0.0019 - val_acc: 0.7033 - val_mean_absolute_error: 0.0313 - val_mean_squared_error: 0.0019
Epoch 44/50
1712/1712 [==============================] - 1s - loss: 0.0028 - acc: 0.7179 - mean_absolute_error: 0.0387 - mean_squared_error: 0.0028 - val_loss: 0.0020 - val_acc: 0.7056 - val_mean_absolute_error: 0.0317 - val_mean_squared_error: 0.0020
Epoch 45/50
1712/1712 [==============================] - 1s - loss: 0.0027 - acc: 0.7261 - mean_absolute_error: 0.0382 - mean_squared_error: 0.0027 - val_loss: 0.0019 - val_acc: 0.7009 - val_mean_absolute_error: 0.0312 - val_mean_squared_error: 0.0019
Epoch 46/50
1712/1712 [==============================] - 1s - loss: 0.0026 - acc: 0.7173 - mean_absolute_error: 0.0373 - mean_squared_error: 0.0026 - val_loss: 0.0018 - val_acc: 0.6986 - val_mean_absolute_error: 0.0306 - val_mean_squared_error: 0.0018
Epoch 47/50
1712/1712 [==============================] - 1s - loss: 0.0025 - acc: 0.7214 - mean_absolute_error: 0.0372 - mean_squared_error: 0.0025 - val_loss: 0.0018 - val_acc: 0.7126 - val_mean_absolute_error: 0.0302 - val_mean_squared_error: 0.0018
Epoch 48/50
1712/1712 [==============================] - 1s - loss: 0.0025 - acc: 0.7220 - mean_absolute_error: 0.0367 - mean_squared_error: 0.0025 - val_loss: 0.0018 - val_acc: 0.7079 - val_mean_absolute_error: 0.0303 - val_mean_squared_error: 0.0018
Epoch 49/50
1712/1712 [==============================] - 1s - loss: 0.0024 - acc: 0.7307 - mean_absolute_error: 0.0360 - mean_squared_error: 0.0024 - val_loss: 0.0019 - val_acc: 0.7079 - val_mean_absolute_error: 0.0308 - val_mean_squared_error: 0.0019
Epoch 50/50
1712/1712 [==============================] - 1s - loss: 0.0023 - acc: 0.7412 - mean_absolute_error: 0.0353 - mean_squared_error: 0.0023 - val_loss: 0.0017 - val_acc: 0.7079 - val_mean_absolute_error: 0.0294 - val_mean_squared_error: 0.0017
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [61]:
model12 = Sequential()
model12.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model12.add(MaxPooling2D(pool_size=(2, 2)))
model12.add(Dropout(0.1))

model12.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model12.add(MaxPooling2D(pool_size=(2, 2)))
model12.add(Dropout(0.2))

model12.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model12.add(MaxPooling2D(pool_size=(2, 2)))
model12.add(Dropout(0.3))

model12.add(Flatten())
model12.add(Dense(256, activation='relu'))
model12.add(Dropout(0.5))
model12.add(Dense(30))

# Summarize the model
model12.summary()

opt = 'Adamax'
epochs = 50
model12.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model12.fit(X_train_all, y_train_all, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_43 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_43 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_52 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_44 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_44 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_53 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_45 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_45 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_54 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_15 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_34 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_55 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_35 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 3424 samples, validate on 856 samples
Epoch 1/50
3424/3424 [==============================] - 2s - loss: 0.0325 - acc: 0.4176 - mean_absolute_error: 0.1355 - mean_squared_error: 0.0325 - val_loss: 0.0366 - val_acc: 0.6600 - val_mean_absolute_error: 0.1580 - val_mean_squared_error: 0.0366
Epoch 2/50
3424/3424 [==============================] - 2s - loss: 0.0138 - acc: 0.5245 - mean_absolute_error: 0.0913 - mean_squared_error: 0.0138 - val_loss: 0.0243 - val_acc: 0.6600 - val_mean_absolute_error: 0.1260 - val_mean_squared_error: 0.0243
Epoch 3/50
3424/3424 [==============================] - 2s - loss: 0.0114 - acc: 0.5473 - mean_absolute_error: 0.0823 - mean_squared_error: 0.0114 - val_loss: 0.0231 - val_acc: 0.6600 - val_mean_absolute_error: 0.1231 - val_mean_squared_error: 0.0231
Epoch 4/50
3424/3424 [==============================] - 2s - loss: 0.0099 - acc: 0.5940 - mean_absolute_error: 0.0763 - mean_squared_error: 0.0099 - val_loss: 0.0194 - val_acc: 0.6600 - val_mean_absolute_error: 0.1122 - val_mean_squared_error: 0.0194
Epoch 5/50
3424/3424 [==============================] - 2s - loss: 0.0088 - acc: 0.5958 - mean_absolute_error: 0.0719 - mean_squared_error: 0.0088 - val_loss: 0.0124 - val_acc: 0.6600 - val_mean_absolute_error: 0.0861 - val_mean_squared_error: 0.0124
Epoch 6/50
3424/3424 [==============================] - 2s - loss: 0.0081 - acc: 0.6121 - mean_absolute_error: 0.0687 - mean_squared_error: 0.0081 - val_loss: 0.0083 - val_acc: 0.6600 - val_mean_absolute_error: 0.0696 - val_mean_squared_error: 0.0083
Epoch 7/50
3424/3424 [==============================] - 2s - loss: 0.0077 - acc: 0.6332 - mean_absolute_error: 0.0669 - mean_squared_error: 0.0077 - val_loss: 0.0092 - val_acc: 0.6600 - val_mean_absolute_error: 0.0733 - val_mean_squared_error: 0.0092
Epoch 8/50
3424/3424 [==============================] - 2s - loss: 0.0070 - acc: 0.6224 - mean_absolute_error: 0.0637 - mean_squared_error: 0.0070 - val_loss: 0.0077 - val_acc: 0.6624 - val_mean_absolute_error: 0.0676 - val_mean_squared_error: 0.0077
Epoch 9/50
3424/3424 [==============================] - 2s - loss: 0.0066 - acc: 0.6489 - mean_absolute_error: 0.0613 - mean_squared_error: 0.0066 - val_loss: 0.0074 - val_acc: 0.6636 - val_mean_absolute_error: 0.0660 - val_mean_squared_error: 0.0074
Epoch 10/50
3424/3424 [==============================] - 2s - loss: 0.0063 - acc: 0.6612 - mean_absolute_error: 0.0598 - mean_squared_error: 0.0063 - val_loss: 0.0058 - val_acc: 0.6612 - val_mean_absolute_error: 0.0570 - val_mean_squared_error: 0.0058
Epoch 11/50
3424/3424 [==============================] - 2s - loss: 0.0058 - acc: 0.6510 - mean_absolute_error: 0.0571 - mean_squared_error: 0.0058 - val_loss: 0.0055 - val_acc: 0.6671 - val_mean_absolute_error: 0.0562 - val_mean_squared_error: 0.0055
Epoch 12/50
3424/3424 [==============================] - 2s - loss: 0.0054 - acc: 0.6679 - mean_absolute_error: 0.0551 - mean_squared_error: 0.0054 - val_loss: 0.0046 - val_acc: 0.6659 - val_mean_absolute_error: 0.0508 - val_mean_squared_error: 0.0046
Epoch 13/50
3424/3424 [==============================] - 2s - loss: 0.0050 - acc: 0.6755 - mean_absolute_error: 0.0531 - mean_squared_error: 0.0050 - val_loss: 0.0037 - val_acc: 0.6717 - val_mean_absolute_error: 0.0452 - val_mean_squared_error: 0.0037
Epoch 14/50
3424/3424 [==============================] - 2s - loss: 0.0047 - acc: 0.6653 - mean_absolute_error: 0.0514 - mean_squared_error: 0.0047 - val_loss: 0.0037 - val_acc: 0.6659 - val_mean_absolute_error: 0.0452 - val_mean_squared_error: 0.0037
Epoch 15/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6744 - mean_absolute_error: 0.0499 - mean_squared_error: 0.0045 - val_loss: 0.0040 - val_acc: 0.6694 - val_mean_absolute_error: 0.0472 - val_mean_squared_error: 0.0040
Epoch 16/50
3424/3424 [==============================] - 2s - loss: 0.0043 - acc: 0.6738 - mean_absolute_error: 0.0488 - mean_squared_error: 0.0043 - val_loss: 0.0031 - val_acc: 0.6682 - val_mean_absolute_error: 0.0408 - val_mean_squared_error: 0.0031
Epoch 17/50
3424/3424 [==============================] - 2s - loss: 0.0040 - acc: 0.6749 - mean_absolute_error: 0.0468 - mean_squared_error: 0.0040 - val_loss: 0.0027 - val_acc: 0.6741 - val_mean_absolute_error: 0.0378 - val_mean_squared_error: 0.0027
Epoch 18/50
3424/3424 [==============================] - 2s - loss: 0.0037 - acc: 0.6843 - mean_absolute_error: 0.0452 - mean_squared_error: 0.0037 - val_loss: 0.0027 - val_acc: 0.6846 - val_mean_absolute_error: 0.0378 - val_mean_squared_error: 0.0027
Epoch 19/50
3424/3424 [==============================] - 2s - loss: 0.0035 - acc: 0.6875 - mean_absolute_error: 0.0437 - mean_squared_error: 0.0035 - val_loss: 0.0024 - val_acc: 0.6694 - val_mean_absolute_error: 0.0356 - val_mean_squared_error: 0.0024
Epoch 20/50
3424/3424 [==============================] - 2s - loss: 0.0032 - acc: 0.6922 - mean_absolute_error: 0.0420 - mean_squared_error: 0.0032 - val_loss: 0.0023 - val_acc: 0.6694 - val_mean_absolute_error: 0.0350 - val_mean_squared_error: 0.0023
Epoch 21/50
3424/3424 [==============================] - 2s - loss: 0.0032 - acc: 0.6974 - mean_absolute_error: 0.0413 - mean_squared_error: 0.0032 - val_loss: 0.0023 - val_acc: 0.6706 - val_mean_absolute_error: 0.0348 - val_mean_squared_error: 0.0023
Epoch 22/50
3424/3424 [==============================] - 2s - loss: 0.0030 - acc: 0.6968 - mean_absolute_error: 0.0404 - mean_squared_error: 0.0030 - val_loss: 0.0022 - val_acc: 0.6846 - val_mean_absolute_error: 0.0335 - val_mean_squared_error: 0.0022
Epoch 23/50
3424/3424 [==============================] - 2s - loss: 0.0029 - acc: 0.7094 - mean_absolute_error: 0.0392 - mean_squared_error: 0.0029 - val_loss: 0.0021 - val_acc: 0.6869 - val_mean_absolute_error: 0.0332 - val_mean_squared_error: 0.0021
Epoch 24/50
3424/3424 [==============================] - 2s - loss: 0.0028 - acc: 0.7112 - mean_absolute_error: 0.0386 - mean_squared_error: 0.0028 - val_loss: 0.0021 - val_acc: 0.6822 - val_mean_absolute_error: 0.0331 - val_mean_squared_error: 0.0021
Epoch 25/50
3424/3424 [==============================] - 2s - loss: 0.0026 - acc: 0.7004 - mean_absolute_error: 0.0372 - mean_squared_error: 0.0026 - val_loss: 0.0020 - val_acc: 0.6857 - val_mean_absolute_error: 0.0319 - val_mean_squared_error: 0.0020
Epoch 26/50
3424/3424 [==============================] - 2s - loss: 0.0025 - acc: 0.7158 - mean_absolute_error: 0.0367 - mean_squared_error: 0.0025 - val_loss: 0.0020 - val_acc: 0.6916 - val_mean_absolute_error: 0.0318 - val_mean_squared_error: 0.0020
Epoch 27/50
3424/3424 [==============================] - 2s - loss: 0.0024 - acc: 0.7109 - mean_absolute_error: 0.0358 - mean_squared_error: 0.0024 - val_loss: 0.0019 - val_acc: 0.6893 - val_mean_absolute_error: 0.0314 - val_mean_squared_error: 0.0019
Epoch 28/50
3424/3424 [==============================] - 2s - loss: 0.0024 - acc: 0.7141 - mean_absolute_error: 0.0354 - mean_squared_error: 0.0024 - val_loss: 0.0018 - val_acc: 0.6916 - val_mean_absolute_error: 0.0306 - val_mean_squared_error: 0.0018
Epoch 29/50
3424/3424 [==============================] - 2s - loss: 0.0023 - acc: 0.7217 - mean_absolute_error: 0.0350 - mean_squared_error: 0.0023 - val_loss: 0.0018 - val_acc: 0.7044 - val_mean_absolute_error: 0.0304 - val_mean_squared_error: 0.0018
Epoch 30/50
3424/3424 [==============================] - 2s - loss: 0.0023 - acc: 0.7164 - mean_absolute_error: 0.0346 - mean_squared_error: 0.0023 - val_loss: 0.0017 - val_acc: 0.7044 - val_mean_absolute_error: 0.0298 - val_mean_squared_error: 0.0017
Epoch 31/50
3424/3424 [==============================] - 2s - loss: 0.0022 - acc: 0.7243 - mean_absolute_error: 0.0341 - mean_squared_error: 0.0022 - val_loss: 0.0017 - val_acc: 0.7068 - val_mean_absolute_error: 0.0295 - val_mean_squared_error: 0.0017
Epoch 32/50
3424/3424 [==============================] - 2s - loss: 0.0022 - acc: 0.7202 - mean_absolute_error: 0.0337 - mean_squared_error: 0.0022 - val_loss: 0.0017 - val_acc: 0.7044 - val_mean_absolute_error: 0.0291 - val_mean_squared_error: 0.0017
Epoch 33/50
3424/3424 [==============================] - 2s - loss: 0.0021 - acc: 0.7255 - mean_absolute_error: 0.0331 - mean_squared_error: 0.0021 - val_loss: 0.0016 - val_acc: 0.7044 - val_mean_absolute_error: 0.0286 - val_mean_squared_error: 0.0016
Epoch 34/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7249 - mean_absolute_error: 0.0330 - mean_squared_error: 0.0020 - val_loss: 0.0016 - val_acc: 0.7079 - val_mean_absolute_error: 0.0287 - val_mean_squared_error: 0.0016
Epoch 35/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7173 - mean_absolute_error: 0.0324 - mean_squared_error: 0.0020 - val_loss: 0.0015 - val_acc: 0.7243 - val_mean_absolute_error: 0.0278 - val_mean_squared_error: 0.0015
Epoch 36/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7319 - mean_absolute_error: 0.0323 - mean_squared_error: 0.0020 - val_loss: 0.0015 - val_acc: 0.7243 - val_mean_absolute_error: 0.0277 - val_mean_squared_error: 0.0015
Epoch 37/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7342 - mean_absolute_error: 0.0320 - mean_squared_error: 0.0020 - val_loss: 0.0014 - val_acc: 0.7231 - val_mean_absolute_error: 0.0271 - val_mean_squared_error: 0.0014
Epoch 38/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7310 - mean_absolute_error: 0.0319 - mean_squared_error: 0.0019 - val_loss: 0.0015 - val_acc: 0.7079 - val_mean_absolute_error: 0.0278 - val_mean_squared_error: 0.0015
Epoch 39/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7415 - mean_absolute_error: 0.0315 - mean_squared_error: 0.0019 - val_loss: 0.0014 - val_acc: 0.7395 - val_mean_absolute_error: 0.0265 - val_mean_squared_error: 0.0014
Epoch 40/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7418 - mean_absolute_error: 0.0314 - mean_squared_error: 0.0019 - val_loss: 0.0014 - val_acc: 0.7558 - val_mean_absolute_error: 0.0265 - val_mean_squared_error: 0.0014
Epoch 41/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7450 - mean_absolute_error: 0.0309 - mean_squared_error: 0.0018 - val_loss: 0.0014 - val_acc: 0.7465 - val_mean_absolute_error: 0.0266 - val_mean_squared_error: 0.0014
Epoch 42/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7436 - mean_absolute_error: 0.0309 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7687 - val_mean_absolute_error: 0.0260 - val_mean_squared_error: 0.0013
Epoch 43/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7459 - mean_absolute_error: 0.0306 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7547 - val_mean_absolute_error: 0.0259 - val_mean_squared_error: 0.0013
Epoch 44/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7442 - mean_absolute_error: 0.0305 - mean_squared_error: 0.0017 - val_loss: 0.0014 - val_acc: 0.7570 - val_mean_absolute_error: 0.0266 - val_mean_squared_error: 0.0014
Epoch 45/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7474 - mean_absolute_error: 0.0304 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7815 - val_mean_absolute_error: 0.0260 - val_mean_squared_error: 0.0013
Epoch 46/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7503 - mean_absolute_error: 0.0304 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7839 - val_mean_absolute_error: 0.0254 - val_mean_squared_error: 0.0013
Epoch 47/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7538 - mean_absolute_error: 0.0300 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7582 - val_mean_absolute_error: 0.0256 - val_mean_squared_error: 0.0013
Epoch 48/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7512 - mean_absolute_error: 0.0298 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7722 - val_mean_absolute_error: 0.0245 - val_mean_squared_error: 0.0012
Epoch 49/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7579 - mean_absolute_error: 0.0295 - mean_squared_error: 0.0016 - val_loss: 0.0013 - val_acc: 0.7582 - val_mean_absolute_error: 0.0257 - val_mean_squared_error: 0.0013
Epoch 50/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7579 - mean_absolute_error: 0.0296 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7734 - val_mean_absolute_error: 0.0251 - val_mean_squared_error: 0.0012
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [62]:
model13 = Sequential()
model13.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model13.add(MaxPooling2D(pool_size=(2, 2)))
model13.add(Dropout(0.1))

model13.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model13.add(MaxPooling2D(pool_size=(2, 2)))
model13.add(Dropout(0.2))

model13.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model13.add(MaxPooling2D(pool_size=(2, 2)))
model13.add(Dropout(0.3))

model13.add(Flatten())
model13.add(Dense(256, activation='relu'))
model13.add(Dropout(0.5))
model13.add(Dense(30))

# Summarize the model
model13.summary()

opt = 'Adam'
epochs = 50
model13.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model13.fit(X_train_all, y_train_all, validation_split=0.2, epochs=epochs)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_46 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_46 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_56 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_47 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_47 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_57 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_48 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_48 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_58 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_16 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_36 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_59 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_37 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 3424 samples, validate on 856 samples
Epoch 1/50
3424/3424 [==============================] - 2s - loss: 0.0239 - acc: 0.4121 - mean_absolute_error: 0.1150 - mean_squared_error: 0.0239 - val_loss: 0.0273 - val_acc: 0.6600 - val_mean_absolute_error: 0.1351 - val_mean_squared_error: 0.0273
Epoch 2/50
3424/3424 [==============================] - 2s - loss: 0.0093 - acc: 0.5572 - mean_absolute_error: 0.0742 - mean_squared_error: 0.0093 - val_loss: 0.0180 - val_acc: 0.6600 - val_mean_absolute_error: 0.1078 - val_mean_squared_error: 0.0180
Epoch 3/50
3424/3424 [==============================] - 2s - loss: 0.0073 - acc: 0.5975 - mean_absolute_error: 0.0653 - mean_squared_error: 0.0073 - val_loss: 0.0106 - val_acc: 0.6600 - val_mean_absolute_error: 0.0806 - val_mean_squared_error: 0.0106
Epoch 4/50
3424/3424 [==============================] - 2s - loss: 0.0062 - acc: 0.6308 - mean_absolute_error: 0.0592 - mean_squared_error: 0.0062 - val_loss: 0.0065 - val_acc: 0.6600 - val_mean_absolute_error: 0.0610 - val_mean_squared_error: 0.0065
Epoch 5/50
3424/3424 [==============================] - 2s - loss: 0.0055 - acc: 0.6530 - mean_absolute_error: 0.0556 - mean_squared_error: 0.0055 - val_loss: 0.0057 - val_acc: 0.6612 - val_mean_absolute_error: 0.0573 - val_mean_squared_error: 0.0057
Epoch 6/50
3424/3424 [==============================] - 2s - loss: 0.0050 - acc: 0.6700 - mean_absolute_error: 0.0526 - mean_squared_error: 0.0050 - val_loss: 0.0045 - val_acc: 0.6624 - val_mean_absolute_error: 0.0503 - val_mean_squared_error: 0.0045
Epoch 7/50
3424/3424 [==============================] - 2s - loss: 0.0045 - acc: 0.6691 - mean_absolute_error: 0.0496 - mean_squared_error: 0.0045 - val_loss: 0.0042 - val_acc: 0.6752 - val_mean_absolute_error: 0.0484 - val_mean_squared_error: 0.0042
Epoch 8/50
3424/3424 [==============================] - 2s - loss: 0.0041 - acc: 0.6755 - mean_absolute_error: 0.0475 - mean_squared_error: 0.0041 - val_loss: 0.0030 - val_acc: 0.6893 - val_mean_absolute_error: 0.0401 - val_mean_squared_error: 0.0030
Epoch 9/50
3424/3424 [==============================] - 2s - loss: 0.0038 - acc: 0.6968 - mean_absolute_error: 0.0455 - mean_squared_error: 0.0038 - val_loss: 0.0027 - val_acc: 0.6787 - val_mean_absolute_error: 0.0375 - val_mean_squared_error: 0.0027
Epoch 10/50
3424/3424 [==============================] - 2s - loss: 0.0036 - acc: 0.6983 - mean_absolute_error: 0.0439 - mean_squared_error: 0.0036 - val_loss: 0.0022 - val_acc: 0.6881 - val_mean_absolute_error: 0.0342 - val_mean_squared_error: 0.0022
Epoch 11/50
3424/3424 [==============================] - 2s - loss: 0.0034 - acc: 0.7009 - mean_absolute_error: 0.0428 - mean_squared_error: 0.0034 - val_loss: 0.0024 - val_acc: 0.7056 - val_mean_absolute_error: 0.0353 - val_mean_squared_error: 0.0024
Epoch 12/50
3424/3424 [==============================] - 2s - loss: 0.0032 - acc: 0.6980 - mean_absolute_error: 0.0417 - mean_squared_error: 0.0032 - val_loss: 0.0024 - val_acc: 0.6893 - val_mean_absolute_error: 0.0351 - val_mean_squared_error: 0.0024
Epoch 13/50
3424/3424 [==============================] - 2s - loss: 0.0030 - acc: 0.7117 - mean_absolute_error: 0.0401 - mean_squared_error: 0.0030 - val_loss: 0.0024 - val_acc: 0.6998 - val_mean_absolute_error: 0.0349 - val_mean_squared_error: 0.0024
Epoch 14/50
3424/3424 [==============================] - 2s - loss: 0.0029 - acc: 0.7158 - mean_absolute_error: 0.0392 - mean_squared_error: 0.0029 - val_loss: 0.0020 - val_acc: 0.7056 - val_mean_absolute_error: 0.0323 - val_mean_squared_error: 0.0020
Epoch 15/50
3424/3424 [==============================] - 2s - loss: 0.0028 - acc: 0.7176 - mean_absolute_error: 0.0384 - mean_squared_error: 0.0028 - val_loss: 0.0019 - val_acc: 0.7114 - val_mean_absolute_error: 0.0308 - val_mean_squared_error: 0.0019
Epoch 16/50
3424/3424 [==============================] - 2s - loss: 0.0026 - acc: 0.7217 - mean_absolute_error: 0.0372 - mean_squared_error: 0.0026 - val_loss: 0.0019 - val_acc: 0.7208 - val_mean_absolute_error: 0.0312 - val_mean_squared_error: 0.0019
Epoch 17/50
3424/3424 [==============================] - 2s - loss: 0.0025 - acc: 0.7234 - mean_absolute_error: 0.0363 - mean_squared_error: 0.0025 - val_loss: 0.0017 - val_acc: 0.7453 - val_mean_absolute_error: 0.0297 - val_mean_squared_error: 0.0017
Epoch 18/50
3424/3424 [==============================] - 2s - loss: 0.0024 - acc: 0.7258 - mean_absolute_error: 0.0355 - mean_squared_error: 0.0024 - val_loss: 0.0017 - val_acc: 0.7488 - val_mean_absolute_error: 0.0296 - val_mean_squared_error: 0.0017
Epoch 19/50
3424/3424 [==============================] - 2s - loss: 0.0023 - acc: 0.7418 - mean_absolute_error: 0.0350 - mean_squared_error: 0.0023 - val_loss: 0.0017 - val_acc: 0.7266 - val_mean_absolute_error: 0.0299 - val_mean_squared_error: 0.0017
Epoch 20/50
3424/3424 [==============================] - 2s - loss: 0.0022 - acc: 0.7331 - mean_absolute_error: 0.0340 - mean_squared_error: 0.0022 - val_loss: 0.0016 - val_acc: 0.7558 - val_mean_absolute_error: 0.0285 - val_mean_squared_error: 0.0016
Epoch 21/50
3424/3424 [==============================] - 2s - loss: 0.0021 - acc: 0.7310 - mean_absolute_error: 0.0335 - mean_squared_error: 0.0021 - val_loss: 0.0016 - val_acc: 0.7570 - val_mean_absolute_error: 0.0281 - val_mean_squared_error: 0.0016
Epoch 22/50
3424/3424 [==============================] - 2s - loss: 0.0021 - acc: 0.7409 - mean_absolute_error: 0.0331 - mean_squared_error: 0.0021 - val_loss: 0.0016 - val_acc: 0.7547 - val_mean_absolute_error: 0.0286 - val_mean_squared_error: 0.0016
Epoch 23/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7409 - mean_absolute_error: 0.0325 - mean_squared_error: 0.0020 - val_loss: 0.0014 - val_acc: 0.7629 - val_mean_absolute_error: 0.0271 - val_mean_squared_error: 0.0014
Epoch 24/50
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7409 - mean_absolute_error: 0.0323 - mean_squared_error: 0.0020 - val_loss: 0.0015 - val_acc: 0.7593 - val_mean_absolute_error: 0.0273 - val_mean_squared_error: 0.0015
Epoch 25/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7430 - mean_absolute_error: 0.0320 - mean_squared_error: 0.0019 - val_loss: 0.0014 - val_acc: 0.7804 - val_mean_absolute_error: 0.0274 - val_mean_squared_error: 0.0014
Epoch 26/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7544 - mean_absolute_error: 0.0313 - mean_squared_error: 0.0019 - val_loss: 0.0013 - val_acc: 0.7734 - val_mean_absolute_error: 0.0263 - val_mean_squared_error: 0.0013
Epoch 27/50
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7462 - mean_absolute_error: 0.0314 - mean_squared_error: 0.0019 - val_loss: 0.0013 - val_acc: 0.7664 - val_mean_absolute_error: 0.0262 - val_mean_squared_error: 0.0013
Epoch 28/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7503 - mean_absolute_error: 0.0309 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7687 - val_mean_absolute_error: 0.0256 - val_mean_squared_error: 0.0013
Epoch 29/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7374 - mean_absolute_error: 0.0308 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7687 - val_mean_absolute_error: 0.0260 - val_mean_squared_error: 0.0013
Epoch 30/50
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7453 - mean_absolute_error: 0.0306 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7652 - val_mean_absolute_error: 0.0256 - val_mean_squared_error: 0.0013
Epoch 31/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7494 - mean_absolute_error: 0.0304 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7710 - val_mean_absolute_error: 0.0251 - val_mean_squared_error: 0.0012
Epoch 32/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7512 - mean_absolute_error: 0.0301 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7792 - val_mean_absolute_error: 0.0257 - val_mean_squared_error: 0.0013
Epoch 33/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7503 - mean_absolute_error: 0.0297 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7769 - val_mean_absolute_error: 0.0248 - val_mean_squared_error: 0.0012
Epoch 34/50
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7564 - mean_absolute_error: 0.0298 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7699 - val_mean_absolute_error: 0.0246 - val_mean_squared_error: 0.0012
Epoch 35/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7544 - mean_absolute_error: 0.0297 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7804 - val_mean_absolute_error: 0.0251 - val_mean_squared_error: 0.0012
Epoch 36/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7500 - mean_absolute_error: 0.0295 - mean_squared_error: 0.0016 - val_loss: 0.0013 - val_acc: 0.7909 - val_mean_absolute_error: 0.0254 - val_mean_squared_error: 0.0013
Epoch 37/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7561 - mean_absolute_error: 0.0293 - mean_squared_error: 0.0016 - val_loss: 0.0011 - val_acc: 0.7956 - val_mean_absolute_error: 0.0238 - val_mean_squared_error: 0.00110.0016 - acc: 0.7479 - mean_absolute_error: 0.0294 - me
Epoch 38/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7585 - mean_absolute_error: 0.0293 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7909 - val_mean_absolute_error: 0.0252 - val_mean_squared_error: 0.0012
Epoch 39/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7523 - mean_absolute_error: 0.0291 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7780 - val_mean_absolute_error: 0.0248 - val_mean_squared_error: 0.0012
Epoch 40/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7523 - mean_absolute_error: 0.0291 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7745 - val_mean_absolute_error: 0.0245 - val_mean_squared_error: 0.0012
Epoch 41/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7602 - mean_absolute_error: 0.0292 - mean_squared_error: 0.0016 - val_loss: 0.0011 - val_acc: 0.7780 - val_mean_absolute_error: 0.0244 - val_mean_squared_error: 0.0011
Epoch 42/50
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7593 - mean_absolute_error: 0.0289 - mean_squared_error: 0.0016 - val_loss: 0.0011 - val_acc: 0.7874 - val_mean_absolute_error: 0.0242 - val_mean_squared_error: 0.0011
Epoch 43/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7506 - mean_absolute_error: 0.0286 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7921 - val_mean_absolute_error: 0.0241 - val_mean_squared_error: 0.0011 0s - loss: 0.0015 - acc: 0.7509 - mean_absolute_error: 0.0286 
Epoch 44/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7593 - mean_absolute_error: 0.0288 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7874 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 45/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7564 - mean_absolute_error: 0.0287 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7745 - val_mean_absolute_error: 0.0241 - val_mean_squared_error: 0.0011
Epoch 46/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7570 - mean_absolute_error: 0.0288 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7827 - val_mean_absolute_error: 0.0242 - val_mean_squared_error: 0.0011
Epoch 47/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7599 - mean_absolute_error: 0.0283 - mean_squared_error: 0.0015 - val_loss: 0.0012 - val_acc: 0.7780 - val_mean_absolute_error: 0.0246 - val_mean_squared_error: 0.0012
Epoch 48/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7588 - mean_absolute_error: 0.0287 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7850 - val_mean_absolute_error: 0.0237 - val_mean_squared_error: 0.0011
Epoch 49/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7634 - mean_absolute_error: 0.0285 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7921 - val_mean_absolute_error: 0.0236 - val_mean_squared_error: 0.0011
Epoch 50/50
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7535 - mean_absolute_error: 0.0283 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.8002 - val_mean_absolute_error: 0.0233 - val_mean_squared_error: 0.0011
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

In [ ]:
# looks like Adamax is still the winner over SGD + Nesterov and using augemented data has improved the validation
# accuracy by almost 7% over the non augmented data to val_acc: 0.7734
# However Adam seems to get slightly better validation accuracy at val_acc: 0.8002
# so lets give it a try on a longer run

In [63]:
model14 = Sequential()
model14.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
model14.add(MaxPooling2D(pool_size=(2, 2)))
model14.add(Dropout(0.1))

model14.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
model14.add(MaxPooling2D(pool_size=(2, 2)))
model14.add(Dropout(0.2))

model14.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
model14.add(MaxPooling2D(pool_size=(2, 2)))
model14.add(Dropout(0.3))

model14.add(Flatten())
model14.add(Dense(256, activation='relu'))
model14.add(Dropout(0.5))
model14.add(Dense(30))

# Summarize the model
model14.summary()

from keras.callbacks import ModelCheckpoint, EarlyStopping
opt = 'Adam'
epochs = 400
early = EarlyStopping(monitor='val_loss', min_delta=0, patience=150, verbose=0, mode='auto')
model_file = './model14_adam_long.hdf5'
checkpointer = ModelCheckpoint(filepath=model_file, verbose=0, save_best_only=True)
model14.compile(loss='mean_squared_error', optimizer=opt, metrics=['acc', 'mae', 'mse'])
hist = model14.fit(X_train_all, y_train_all, validation_split=0.2, epochs=epochs, callbacks=[early, checkpointer], shuffle=True)
show_history_graph(hist)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_49 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_49 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_60 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_50 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_50 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_61 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_51 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_51 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_62 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_17 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_38 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_63 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_39 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________
Train on 3424 samples, validate on 856 samples
Epoch 1/400
3424/3424 [==============================] - 3s - loss: 0.0231 - acc: 0.3987 - mean_absolute_error: 0.1135 - mean_squared_error: 0.0231 - val_loss: 0.0293 - val_acc: 0.6600 - val_mean_absolute_error: 0.1397 - val_mean_squared_error: 0.0293
Epoch 2/400
3424/3424 [==============================] - 2s - loss: 0.0091 - acc: 0.5572 - mean_absolute_error: 0.0737 - mean_squared_error: 0.0091 - val_loss: 0.0210 - val_acc: 0.6600 - val_mean_absolute_error: 0.1173 - val_mean_squared_error: 0.0210
Epoch 3/400
3424/3424 [==============================] - 2s - loss: 0.0075 - acc: 0.6157 - mean_absolute_error: 0.0660 - mean_squared_error: 0.0075 - val_loss: 0.0092 - val_acc: 0.6589 - val_mean_absolute_error: 0.0738 - val_mean_squared_error: 0.0092
Epoch 4/400
3424/3424 [==============================] - 2s - loss: 0.0063 - acc: 0.6466 - mean_absolute_error: 0.0601 - mean_squared_error: 0.0063 - val_loss: 0.0056 - val_acc: 0.6600 - val_mean_absolute_error: 0.0560 - val_mean_squared_error: 0.0056
Epoch 5/400
3424/3424 [==============================] - 2s - loss: 0.0057 - acc: 0.6685 - mean_absolute_error: 0.0565 - mean_squared_error: 0.0057 - val_loss: 0.0051 - val_acc: 0.6682 - val_mean_absolute_error: 0.0538 - val_mean_squared_error: 0.0051
Epoch 6/400
3424/3424 [==============================] - 2s - loss: 0.0049 - acc: 0.6744 - mean_absolute_error: 0.0522 - mean_squared_error: 0.0049 - val_loss: 0.0040 - val_acc: 0.6682 - val_mean_absolute_error: 0.0470 - val_mean_squared_error: 0.0040
Epoch 7/400
3424/3424 [==============================] - 2s - loss: 0.0044 - acc: 0.6916 - mean_absolute_error: 0.0492 - mean_squared_error: 0.0044 - val_loss: 0.0029 - val_acc: 0.6682 - val_mean_absolute_error: 0.0393 - val_mean_squared_error: 0.0029
Epoch 8/400
3424/3424 [==============================] - 2s - loss: 0.0040 - acc: 0.6793 - mean_absolute_error: 0.0468 - mean_squared_error: 0.0040 - val_loss: 0.0028 - val_acc: 0.6811 - val_mean_absolute_error: 0.0378 - val_mean_squared_error: 0.0028
Epoch 9/400
3424/3424 [==============================] - 2s - loss: 0.0038 - acc: 0.6916 - mean_absolute_error: 0.0453 - mean_squared_error: 0.0038 - val_loss: 0.0025 - val_acc: 0.6776 - val_mean_absolute_error: 0.0361 - val_mean_squared_error: 0.0025
Epoch 10/400
3424/3424 [==============================] - 2s - loss: 0.0035 - acc: 0.6945 - mean_absolute_error: 0.0438 - mean_squared_error: 0.0035 - val_loss: 0.0022 - val_acc: 0.6787 - val_mean_absolute_error: 0.0339 - val_mean_squared_error: 0.0022
Epoch 11/400
3424/3424 [==============================] - 2s - loss: 0.0033 - acc: 0.7094 - mean_absolute_error: 0.0423 - mean_squared_error: 0.0033 - val_loss: 0.0021 - val_acc: 0.6834 - val_mean_absolute_error: 0.0328 - val_mean_squared_error: 0.0021
Epoch 12/400
3424/3424 [==============================] - 2s - loss: 0.0031 - acc: 0.7047 - mean_absolute_error: 0.0409 - mean_squared_error: 0.0031 - val_loss: 0.0021 - val_acc: 0.6916 - val_mean_absolute_error: 0.0328 - val_mean_squared_error: 0.0021
Epoch 13/400
3424/3424 [==============================] - 2s - loss: 0.0029 - acc: 0.7091 - mean_absolute_error: 0.0398 - mean_squared_error: 0.0029 - val_loss: 0.0022 - val_acc: 0.6986 - val_mean_absolute_error: 0.0340 - val_mean_squared_error: 0.0022
Epoch 14/400
3424/3424 [==============================] - 2s - loss: 0.0028 - acc: 0.7103 - mean_absolute_error: 0.0387 - mean_squared_error: 0.0028 - val_loss: 0.0020 - val_acc: 0.7091 - val_mean_absolute_error: 0.0316 - val_mean_squared_error: 0.0020
Epoch 15/400
3424/3424 [==============================] - 2s - loss: 0.0027 - acc: 0.7094 - mean_absolute_error: 0.0378 - mean_squared_error: 0.0027 - val_loss: 0.0018 - val_acc: 0.7044 - val_mean_absolute_error: 0.0302 - val_mean_squared_error: 0.0018
Epoch 16/400
3424/3424 [==============================] - 2s - loss: 0.0026 - acc: 0.7147 - mean_absolute_error: 0.0371 - mean_squared_error: 0.0026 - val_loss: 0.0020 - val_acc: 0.6986 - val_mean_absolute_error: 0.0319 - val_mean_squared_error: 0.0020
Epoch 17/400
3424/3424 [==============================] - 2s - loss: 0.0024 - acc: 0.7266 - mean_absolute_error: 0.0361 - mean_squared_error: 0.0024 - val_loss: 0.0017 - val_acc: 0.6974 - val_mean_absolute_error: 0.0295 - val_mean_squared_error: 0.0017
Epoch 18/400
3424/3424 [==============================] - 2s - loss: 0.0024 - acc: 0.7185 - mean_absolute_error: 0.0355 - mean_squared_error: 0.0024 - val_loss: 0.0017 - val_acc: 0.6986 - val_mean_absolute_error: 0.0297 - val_mean_squared_error: 0.0017
Epoch 19/400
3424/3424 [==============================] - 2s - loss: 0.0023 - acc: 0.7278 - mean_absolute_error: 0.0346 - mean_squared_error: 0.0023 - val_loss: 0.0017 - val_acc: 0.7150 - val_mean_absolute_error: 0.0296 - val_mean_squared_error: 0.0017
Epoch 20/400
3424/3424 [==============================] - 2s - loss: 0.0022 - acc: 0.7342 - mean_absolute_error: 0.0340 - mean_squared_error: 0.0022 - val_loss: 0.0017 - val_acc: 0.7021 - val_mean_absolute_error: 0.0293 - val_mean_squared_error: 0.0017
Epoch 21/400
3424/3424 [==============================] - 2s - loss: 0.0021 - acc: 0.7339 - mean_absolute_error: 0.0335 - mean_squared_error: 0.0021 - val_loss: 0.0015 - val_acc: 0.7418 - val_mean_absolute_error: 0.0275 - val_mean_squared_error: 0.0015
Epoch 22/400
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7360 - mean_absolute_error: 0.0329 - mean_squared_error: 0.0020 - val_loss: 0.0015 - val_acc: 0.7301 - val_mean_absolute_error: 0.0273 - val_mean_squared_error: 0.0015
Epoch 23/400
3424/3424 [==============================] - 2s - loss: 0.0020 - acc: 0.7316 - mean_absolute_error: 0.0328 - mean_squared_error: 0.0020 - val_loss: 0.0015 - val_acc: 0.7220 - val_mean_absolute_error: 0.0276 - val_mean_squared_error: 0.0015
Epoch 24/400
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7366 - mean_absolute_error: 0.0322 - mean_squared_error: 0.0019 - val_loss: 0.0015 - val_acc: 0.7196 - val_mean_absolute_error: 0.0274 - val_mean_squared_error: 0.0015
Epoch 25/400
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7497 - mean_absolute_error: 0.0315 - mean_squared_error: 0.0019 - val_loss: 0.0015 - val_acc: 0.7290 - val_mean_absolute_error: 0.0278 - val_mean_squared_error: 0.0015
Epoch 26/400
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7474 - mean_absolute_error: 0.0315 - mean_squared_error: 0.0019 - val_loss: 0.0014 - val_acc: 0.7535 - val_mean_absolute_error: 0.0265 - val_mean_squared_error: 0.0014
Epoch 27/400
3424/3424 [==============================] - 2s - loss: 0.0019 - acc: 0.7442 - mean_absolute_error: 0.0313 - mean_squared_error: 0.0019 - val_loss: 0.0014 - val_acc: 0.7477 - val_mean_absolute_error: 0.0262 - val_mean_squared_error: 0.0014
Epoch 28/400
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7526 - mean_absolute_error: 0.0311 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7442 - val_mean_absolute_error: 0.0260 - val_mean_squared_error: 0.0013
Epoch 29/400
3424/3424 [==============================] - 2s - loss: 0.0018 - acc: 0.7436 - mean_absolute_error: 0.0305 - mean_squared_error: 0.0018 - val_loss: 0.0013 - val_acc: 0.7488 - val_mean_absolute_error: 0.0258 - val_mean_squared_error: 0.0013
Epoch 30/400
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7605 - mean_absolute_error: 0.0303 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7640 - val_mean_absolute_error: 0.0256 - val_mean_squared_error: 0.0013
Epoch 31/400
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7512 - mean_absolute_error: 0.0302 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7558 - val_mean_absolute_error: 0.0255 - val_mean_squared_error: 0.0013
Epoch 32/400
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7459 - mean_absolute_error: 0.0301 - mean_squared_error: 0.0017 - val_loss: 0.0013 - val_acc: 0.7558 - val_mean_absolute_error: 0.0254 - val_mean_squared_error: 0.0013
Epoch 33/400
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7503 - mean_absolute_error: 0.0298 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7664 - val_mean_absolute_error: 0.0248 - val_mean_squared_error: 0.0012
Epoch 34/400
3424/3424 [==============================] - 2s - loss: 0.0017 - acc: 0.7523 - mean_absolute_error: 0.0298 - mean_squared_error: 0.0017 - val_loss: 0.0012 - val_acc: 0.7664 - val_mean_absolute_error: 0.0250 - val_mean_squared_error: 0.0012
Epoch 35/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7439 - mean_absolute_error: 0.0295 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7593 - val_mean_absolute_error: 0.0249 - val_mean_squared_error: 0.0012
Epoch 36/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7515 - mean_absolute_error: 0.0292 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7629 - val_mean_absolute_error: 0.0246 - val_mean_squared_error: 0.0012
Epoch 37/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7579 - mean_absolute_error: 0.0292 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7886 - val_mean_absolute_error: 0.0244 - val_mean_squared_error: 0.0012
Epoch 38/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7503 - mean_absolute_error: 0.0292 - mean_squared_error: 0.0016 - val_loss: 0.0013 - val_acc: 0.7582 - val_mean_absolute_error: 0.0256 - val_mean_squared_error: 0.0013
Epoch 39/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7477 - mean_absolute_error: 0.0290 - mean_squared_error: 0.0016 - val_loss: 0.0012 - val_acc: 0.7780 - val_mean_absolute_error: 0.0247 - val_mean_squared_error: 0.0012
Epoch 40/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7503 - mean_absolute_error: 0.0288 - mean_squared_error: 0.0015 - val_loss: 0.0012 - val_acc: 0.7780 - val_mean_absolute_error: 0.0244 - val_mean_squared_error: 0.0012
Epoch 41/400
3424/3424 [==============================] - 2s - loss: 0.0016 - acc: 0.7602 - mean_absolute_error: 0.0288 - mean_squared_error: 0.0016 - val_loss: 0.0011 - val_acc: 0.7769 - val_mean_absolute_error: 0.0238 - val_mean_squared_error: 0.0011
Epoch 42/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7520 - mean_absolute_error: 0.0288 - mean_squared_error: 0.0015 - val_loss: 0.0012 - val_acc: 0.7699 - val_mean_absolute_error: 0.0245 - val_mean_squared_error: 0.0012
Epoch 43/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7626 - mean_absolute_error: 0.0287 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7745 - val_mean_absolute_error: 0.0241 - val_mean_squared_error: 0.0011
Epoch 44/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7637 - mean_absolute_error: 0.0285 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7862 - val_mean_absolute_error: 0.0241 - val_mean_squared_error: 0.0011
Epoch 45/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7541 - mean_absolute_error: 0.0284 - mean_squared_error: 0.0015 - val_loss: 0.0012 - val_acc: 0.7617 - val_mean_absolute_error: 0.0250 - val_mean_squared_error: 0.0012
Epoch 46/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7611 - mean_absolute_error: 0.0283 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7967 - val_mean_absolute_error: 0.0236 - val_mean_squared_error: 0.0011
Epoch 47/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7614 - mean_absolute_error: 0.0283 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7675 - val_mean_absolute_error: 0.0241 - val_mean_squared_error: 0.0011
Epoch 48/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7573 - mean_absolute_error: 0.0281 - mean_squared_error: 0.0015 - val_loss: 0.0010 - val_acc: 0.7769 - val_mean_absolute_error: 0.0230 - val_mean_squared_error: 0.0010
Epoch 49/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7605 - mean_absolute_error: 0.0280 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7850 - val_mean_absolute_error: 0.0237 - val_mean_squared_error: 0.0011
Epoch 50/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7643 - mean_absolute_error: 0.0281 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.8002 - val_mean_absolute_error: 0.0233 - val_mean_squared_error: 0.0011
Epoch 51/400
3424/3424 [==============================] - 2s - loss: 0.0015 - acc: 0.7614 - mean_absolute_error: 0.0281 - mean_squared_error: 0.0015 - val_loss: 0.0011 - val_acc: 0.7921 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 52/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7649 - mean_absolute_error: 0.0279 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7909 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0010
Epoch 53/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7678 - mean_absolute_error: 0.0278 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7956 - val_mean_absolute_error: 0.0235 - val_mean_squared_error: 0.0011
Epoch 54/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7664 - mean_absolute_error: 0.0279 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7886 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 55/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7696 - mean_absolute_error: 0.0276 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7792 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 56/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7696 - mean_absolute_error: 0.0277 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.8037 - val_mean_absolute_error: 0.0230 - val_mean_squared_error: 0.0010
Epoch 57/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7640 - mean_absolute_error: 0.0275 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7687 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 58/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7664 - mean_absolute_error: 0.0275 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7886 - val_mean_absolute_error: 0.0235 - val_mean_squared_error: 0.0011
Epoch 59/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7579 - mean_absolute_error: 0.0278 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7827 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 60/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7687 - mean_absolute_error: 0.0276 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.8131 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0010
Epoch 61/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7585 - mean_absolute_error: 0.0275 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7967 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 62/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7734 - mean_absolute_error: 0.0275 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7780 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0010
Epoch 63/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7760 - mean_absolute_error: 0.0274 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7839 - val_mean_absolute_error: 0.0233 - val_mean_squared_error: 0.0011
Epoch 64/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7681 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7722 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 65/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7725 - mean_absolute_error: 0.0272 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7710 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0010
Epoch 66/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7687 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0014 - val_loss: 9.9116e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 9.9116e-04
Epoch 67/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7734 - mean_absolute_error: 0.0271 - mean_squared_error: 0.0013 - val_loss: 0.0011 - val_acc: 0.8049 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 68/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7678 - mean_absolute_error: 0.0272 - mean_squared_error: 0.0013 - val_loss: 0.0011 - val_acc: 0.7921 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0011
Epoch 69/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7737 - mean_absolute_error: 0.0272 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7956 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0010
Epoch 70/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7617 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7909 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 71/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7725 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0014 - val_loss: 0.0010 - val_acc: 0.7921 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0010
Epoch 72/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7839 - mean_absolute_error: 0.0272 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7874 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0010
Epoch 73/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7693 - mean_absolute_error: 0.0273 - mean_squared_error: 0.0014 - val_loss: 0.0011 - val_acc: 0.7558 - val_mean_absolute_error: 0.0236 - val_mean_squared_error: 0.0011
Epoch 74/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7643 - mean_absolute_error: 0.0272 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8131 - val_mean_absolute_error: 0.0227 - val_mean_squared_error: 0.0010
Epoch 75/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7745 - mean_absolute_error: 0.0271 - mean_squared_error: 0.0013 - val_loss: 0.0011 - val_acc: 0.8061 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0011
Epoch 76/400
3424/3424 [==============================] - 2s - loss: 0.0014 - acc: 0.7757 - mean_absolute_error: 0.0271 - mean_squared_error: 0.0014 - val_loss: 9.8464e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8464e-04
Epoch 77/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7661 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 9.8193e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8193e-04loss: 0.0013 - acc: 0.7671 - mean
Epoch 78/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7696 - mean_absolute_error: 0.0270 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8026 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 79/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7734 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 0.0011 - val_acc: 0.7699 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0011
Epoch 80/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7704 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7967 - val_mean_absolute_error: 0.0227 - val_mean_squared_error: 0.0010A: 0s - loss: 0.0013 - acc: 0.7705 - mean_absolute_error: 0.0269 - 
Epoch 81/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7713 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 9.9821e-04 - val_acc: 0.7804 - val_mean_absolute_error: 0.0227 - val_mean_squared_error: 9.9821e-04
Epoch 82/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7722 - mean_absolute_error: 0.0268 - mean_squared_error: 0.0013 - val_loss: 9.4825e-04 - val_acc: 0.7804 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.4825e-04
Epoch 83/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7702 - mean_absolute_error: 0.0268 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8026 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 84/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7704 - mean_absolute_error: 0.0268 - mean_squared_error: 0.0013 - val_loss: 9.6994e-04 - val_acc: 0.7886 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6994e-04
Epoch 85/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7591 - mean_absolute_error: 0.0267 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7780 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0010
Epoch 86/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7780 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7839 - val_mean_absolute_error: 0.0227 - val_mean_squared_error: 0.0010
Epoch 87/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7801 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 9.7723e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.7723e-04
Epoch 88/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7713 - mean_absolute_error: 0.0268 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7745 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 0.0010
Epoch 89/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7777 - mean_absolute_error: 0.0269 - mean_squared_error: 0.0013 - val_loss: 9.8773e-04 - val_acc: 0.7839 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 9.8773e-04
Epoch 90/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7777 - mean_absolute_error: 0.0267 - mean_squared_error: 0.0013 - val_loss: 0.0011 - val_acc: 0.7745 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0011
Epoch 91/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7731 - mean_absolute_error: 0.0267 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7932 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 92/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7737 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8037 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 93/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7777 - mean_absolute_error: 0.0268 - mean_squared_error: 0.0013 - val_loss: 9.9773e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 9.9773e-04
Epoch 94/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7804 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 9.5383e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.5383e-04
Epoch 95/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7751 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7710 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 96/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7798 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8037 - val_mean_absolute_error: 0.0234 - val_mean_squared_error: 0.0010
Epoch 97/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7783 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 9.1713e-04 - val_acc: 0.7827 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.1713e-04
Epoch 98/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7795 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.7425e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7425e-04
Epoch 99/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7772 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 9.6829e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6829e-04
Epoch 100/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7737 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 9.5633e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5633e-04
Epoch 101/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7812 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.4181e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4181e-04
Epoch 102/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7932 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.5527e-04 - val_acc: 0.7956 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5527e-04
Epoch 103/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7783 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8014 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 104/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7839 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 9.7845e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7845e-04
Epoch 105/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7777 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.5758e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5758e-04
Epoch 106/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7786 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 9.6654e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6654e-04
Epoch 107/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7728 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.5774e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5774e-04
Epoch 108/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7737 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.4231e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4231e-04
Epoch 109/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7751 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.9120e-04 - val_acc: 0.7874 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.9120e-04
Epoch 110/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7681 - mean_absolute_error: 0.0263 - mean_squared_error: 0.0013 - val_loss: 9.7819e-04 - val_acc: 0.7874 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7819e-04
Epoch 111/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7850 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.6773e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6773e-04
Epoch 112/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7839 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.7376e-04 - val_acc: 0.7640 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7376e-04
Epoch 113/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7833 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7839 - val_mean_absolute_error: 0.0230 - val_mean_squared_error: 0.0010
Epoch 114/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7769 - mean_absolute_error: 0.0266 - mean_squared_error: 0.0013 - val_loss: 9.5910e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5910e-04
Epoch 115/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7757 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7827 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 116/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7874 - mean_absolute_error: 0.0263 - mean_squared_error: 0.0013 - val_loss: 9.4723e-04 - val_acc: 0.7757 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.4723e-04
Epoch 117/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7728 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.9747e-04 - val_acc: 0.7827 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 9.9747e-04
Epoch 118/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7775 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.2744e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2744e-04
Epoch 119/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7725 - mean_absolute_error: 0.0263 - mean_squared_error: 0.0013 - val_loss: 9.9688e-04 - val_acc: 0.7874 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.9688e-04
Epoch 120/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7836 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 9.6305e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6305e-04
Epoch 121/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7775 - mean_absolute_error: 0.0265 - mean_squared_error: 0.0013 - val_loss: 9.7933e-04 - val_acc: 0.7710 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.7933e-04
Epoch 122/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7815 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.3329e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3329e-04
Epoch 123/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7795 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0013 - val_loss: 9.5462e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.5462e-04
Epoch 124/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7874 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.7036e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7036e-04
Epoch 125/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7766 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.8131 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0010
Epoch 126/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7842 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.2671e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2671e-04
Epoch 127/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7757 - mean_absolute_error: 0.0264 - mean_squared_error: 0.0013 - val_loss: 9.7156e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7156e-04
Epoch 128/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7842 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0012 - val_loss: 9.8449e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8449e-04ss: 0.0013 - acc: 0.7882 - mean_absolute_error: 0.0261 - mean_squared_err
Epoch 129/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7833 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.7587e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7587e-04
Epoch 130/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7792 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0012 - val_loss: 9.1481e-04 - val_acc: 0.7862 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1481e-04
Epoch 131/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7798 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0012 - val_loss: 0.0011 - val_acc: 0.7921 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0011
Epoch 132/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7818 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0013 - val_loss: 9.4445e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4445e-04
Epoch 133/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7798 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.9919e-04 - val_acc: 0.7839 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.9919e-04
Epoch 134/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7772 - mean_absolute_error: 0.0263 - mean_squared_error: 0.0013 - val_loss: 9.7546e-04 - val_acc: 0.7780 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7546e-04
Epoch 135/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7871 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7979 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 0.0010
Epoch 136/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7713 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0012 - val_loss: 9.7858e-04 - val_acc: 0.7862 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7858e-04
Epoch 137/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7897 - val_mean_absolute_error: 0.0230 - val_mean_squared_error: 0.0010
Epoch 138/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7731 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.3444e-04 - val_acc: 0.7769 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.3444e-04
Epoch 139/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.7653e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7653e-04
Epoch 140/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7877 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.6733e-04 - val_acc: 0.7956 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.6733e-04
Epoch 141/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7798 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7886 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 0.0010
Epoch 142/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7865 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 0.0010 - val_acc: 0.7862 - val_mean_absolute_error: 0.0229 - val_mean_squared_error: 0.0010
Epoch 143/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7804 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.1741e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.1741e-04
Epoch 144/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7906 - mean_absolute_error: 0.0262 - mean_squared_error: 0.0013 - val_loss: 9.7916e-04 - val_acc: 0.7745 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.7916e-04
Epoch 145/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7842 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 0.0011 - val_acc: 0.7839 - val_mean_absolute_error: 0.0232 - val_mean_squared_error: 0.0011
Epoch 146/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7763 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0013 - val_loss: 9.6458e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6458e-04
Epoch 147/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7812 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 9.4716e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4716e-04
Epoch 148/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 9.6354e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6354e-04
Epoch 149/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7728 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8201 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 150/400
3424/3424 [==============================] - 2s - loss: 0.0013 - acc: 0.7848 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0013 - val_loss: 9.8347e-04 - val_acc: 0.7886 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8347e-04
Epoch 151/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7827 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 9.2812e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.2812e-04
Epoch 152/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.6886e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6886e-04
Epoch 153/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7807 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.5832e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5832e-04
Epoch 154/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7877 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.4093e-04 - val_acc: 0.7862 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4093e-04
Epoch 155/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7775 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 9.5587e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5587e-04
Epoch 156/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7801 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 0.0011 - val_acc: 0.7862 - val_mean_absolute_error: 0.0231 - val_mean_squared_error: 0.0011
Epoch 157/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8014 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 0.0010
Epoch 158/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7798 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.4487e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.4487e-04
Epoch 159/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7731 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.5245e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5245e-04
Epoch 160/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7824 - mean_absolute_error: 0.0261 - mean_squared_error: 0.0012 - val_loss: 9.5338e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5338e-04
Epoch 161/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7836 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.8092e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8092e-04
Epoch 162/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7775 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.8595e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8595e-04
Epoch 163/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.0952e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.0952e-04
Epoch 164/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7953 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6567e-04 - val_acc: 0.8154 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6567e-04
Epoch 165/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7842 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7991 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 0.0010
Epoch 166/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7798 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.6939e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.6939e-04
Epoch 167/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7897 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.8333e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8333e-04
Epoch 168/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7964 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.4601e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4601e-04
Epoch 169/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7830 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.2265e-04 - val_acc: 0.7862 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2265e-04
Epoch 170/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7842 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.7280e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7280e-04
Epoch 171/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7815 - mean_absolute_error: 0.0260 - mean_squared_error: 0.0012 - val_loss: 9.4668e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.4668e-04
Epoch 172/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7812 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7897 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 173/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7850 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 174/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7763 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8084 - val_mean_absolute_error: 0.0228 - val_mean_squared_error: 0.0010
Epoch 175/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7792 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.3990e-04 - val_acc: 0.8201 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.3990e-04
Epoch 176/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.6545e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6545e-04
Epoch 177/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7818 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 8.9908e-04 - val_acc: 0.8236 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 8.9908e-04
Epoch 178/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7888 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.6770e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6770e-04
Epoch 179/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7798 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.0933e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.0933e-04
Epoch 180/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0259 - mean_squared_error: 0.0012 - val_loss: 9.4151e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4151e-04
Epoch 181/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7801 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.0515e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.0515e-04
Epoch 182/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7810 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6070e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.6070e-04
Epoch 183/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7789 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.6255e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6255e-04
Epoch 184/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7935 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.3220e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3220e-04
Epoch 185/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7848 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.5934e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.5934e-04
Epoch 186/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7921 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.6288e-04 - val_acc: 0.8189 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6288e-04
Epoch 187/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7938 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.2104e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2104e-04
Epoch 188/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7926 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7827 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 0.0010
Epoch 189/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7848 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6898e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6898e-04
Epoch 190/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7912 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.9556e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 9.9556e-04
Epoch 191/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7780 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.7198e-04 - val_acc: 0.7979 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7198e-04
Epoch 192/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.4283e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4283e-04
Epoch 193/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7795 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.4737e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4737e-04
Epoch 194/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.2094e-04 - val_acc: 0.7956 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.2094e-04
Epoch 195/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7824 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6309e-04 - val_acc: 0.7827 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6309e-04
Epoch 196/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.8959e-04 - val_acc: 0.7979 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8959e-04
Epoch 197/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7859 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.5162e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5162e-04
Epoch 198/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7754 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.0651e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.0651e-04
Epoch 199/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7953 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.7935e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.7935e-04
Epoch 200/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7888 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.2249e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2249e-04
Epoch 201/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.4819e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.4819e-04
Epoch 202/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7777 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.2988e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2988e-04
Epoch 203/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6183e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6183e-04
Epoch 204/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.7886 - val_mean_absolute_error: 0.0225 - val_mean_squared_error: 0.0010
Epoch 205/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 8.8500e-04 - val_acc: 0.8271 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 8.8500e-04
Epoch 206/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.6435e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6435e-04
Epoch 207/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7848 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.3941e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3941e-04
Epoch 208/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7886 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.8760e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8760e-04
Epoch 209/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7853 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.6153e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.6153e-04
Epoch 210/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7891 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.9577e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.9577e-04
Epoch 211/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7918 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.3037e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.3037e-04
Epoch 212/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7877 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.8871e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8871e-04
Epoch 213/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.8222e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.8222e-04
Epoch 214/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7912 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.4732e-04 - val_acc: 0.8189 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.4732e-04
Epoch 215/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.5463e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5463e-04
Epoch 216/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7853 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.6782e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6782e-04
Epoch 217/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.5107e-04 - val_acc: 0.8201 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.5107e-04
Epoch 218/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7912 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.9487e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 9.9487e-04
Epoch 219/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7918 - mean_absolute_error: 0.0257 - mean_squared_error: 0.0012 - val_loss: 9.4978e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4978e-04
Epoch 220/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7880 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.4715e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4715e-04
Epoch 221/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7807 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.2463e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2463e-04
Epoch 222/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7716 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.4398e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4398e-04
Epoch 223/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7959 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.1881e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1881e-04
Epoch 224/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7918 - mean_absolute_error: 0.0258 - mean_squared_error: 0.0012 - val_loss: 9.5381e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5381e-04
Epoch 225/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7906 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.5855e-04 - val_acc: 0.7979 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5855e-04
Epoch 226/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.3954e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.3954e-04
Epoch 227/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7886 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.0915e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.0915e-04
Epoch 228/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7824 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.0653e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.0653e-04
Epoch 229/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7938 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.7702e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.7702e-04
Epoch 230/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7818 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.6970e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6970e-04
Epoch 231/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7900 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.8386e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.8386e-04
Epoch 232/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7865 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.4363e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4363e-04
Epoch 233/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7888 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.5278e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5278e-04
Epoch 234/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7915 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.8543e-04 - val_acc: 0.8154 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.8543e-04
Epoch 235/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7921 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.0825e-04 - val_acc: 0.8201 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.0825e-04
Epoch 236/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7926 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.7452e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.7452e-04
Epoch 237/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7923 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.3977e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3977e-04
Epoch 238/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7941 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.6091e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6091e-04
Epoch 239/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7888 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.1163e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1163e-04
Epoch 240/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.5698e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5698e-04
Epoch 241/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.7264e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7264e-04
Epoch 242/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7880 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.6977e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6977e-04
Epoch 243/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.5307e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5307e-04
Epoch 244/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 9.5918e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5918e-04
Epoch 245/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7880 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.5114e-04 - val_acc: 0.8154 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5114e-04
Epoch 246/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7985 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.4927e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.4927e-04
Epoch 247/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7886 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2165e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2165e-04
Epoch 248/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7956 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.6376e-04 - val_acc: 0.8189 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6376e-04
Epoch 249/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7947 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.3460e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3460e-04
Epoch 250/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7900 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8014 - val_mean_absolute_error: 0.0224 - val_mean_squared_error: 0.0010
Epoch 251/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7888 - mean_absolute_error: 0.0256 - mean_squared_error: 0.0012 - val_loss: 8.9985e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 8.9985e-04
Epoch 252/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7877 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.3438e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.3438e-04
Epoch 253/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7923 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 8.9749e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 8.9749e-04
Epoch 254/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.6200e-04 - val_acc: 0.7897 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.6200e-04
Epoch 255/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7944 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.7206e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7206e-04
Epoch 256/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1150e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1150e-04
Epoch 257/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7874 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 8.9861e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 8.9861e-04
Epoch 258/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7935 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.2830e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.2830e-04
Epoch 259/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7827 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.3848e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3848e-04
Epoch 260/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1132e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1132e-04
Epoch 261/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7982 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.2637e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2637e-04
Epoch 262/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.6112e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6112e-04
Epoch 263/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7964 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.9315e-04 - val_acc: 0.7886 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.9315e-04
Epoch 264/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1226e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1226e-04
Epoch 265/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7842 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.2307e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2307e-04
Epoch 266/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7862 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.2462e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2462e-04
Epoch 267/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7874 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1219e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1219e-04
Epoch 268/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7976 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.6793e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6793e-04
Epoch 269/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7994 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.5398e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5398e-04
Epoch 270/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2637e-04 - val_acc: 0.7745 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2637e-04
Epoch 271/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7964 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1983e-04 - val_acc: 0.7780 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1983e-04
Epoch 272/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7959 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.4840e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4840e-04
Epoch 273/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7891 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.5902e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5902e-04
Epoch 274/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7909 - mean_absolute_error: 0.0255 - mean_squared_error: 0.0012 - val_loss: 9.3800e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3800e-04
Epoch 275/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7979 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.0598e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.0598e-04
Epoch 276/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7950 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.0338e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.0338e-04
Epoch 277/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7950 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.2515e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.2515e-04
Epoch 278/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7845 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.4042e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.4042e-04
Epoch 279/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7938 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1254e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 9.1254e-04
Epoch 280/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7775 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2316e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.2316e-04
Epoch 281/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7926 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.8085e-04 - val_acc: 0.7956 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8085e-04
Epoch 282/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7897 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.1734e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1734e-04
Epoch 283/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7941 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.0987e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.0987e-04
Epoch 284/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7941 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.8399e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8399e-04
Epoch 285/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7865 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.2907e-04 - val_acc: 0.8189 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2907e-04
Epoch 286/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 8.9255e-04 - val_acc: 0.8283 - val_mean_absolute_error: 0.0212 - val_mean_squared_error: 8.9255e-04
Epoch 287/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7883 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1564e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1564e-04
Epoch 288/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.8011 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.4249e-04 - val_acc: 0.8201 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.4249e-04
Epoch 289/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7880 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.6213e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6213e-04
Epoch 290/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7871 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.6069e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6069e-04
Epoch 291/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7868 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8131 - val_mean_absolute_error: 0.0227 - val_mean_squared_error: 0.0010
Epoch 292/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7953 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.6015e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6015e-04
Epoch 293/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7891 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 8.9647e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 8.9647e-04
Epoch 294/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7836 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.5839e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5839e-04
Epoch 295/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7970 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.6898e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6898e-04
Epoch 296/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7859 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.7440e-04 - val_acc: 0.7827 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7440e-04
Epoch 297/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7964 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1128e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1128e-04
Epoch 298/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7985 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.2488e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2488e-04
Epoch 299/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5582e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5582e-04
Epoch 300/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7923 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.1349e-04 - val_acc: 0.8213 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1349e-04
Epoch 301/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7964 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.4997e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4997e-04
Epoch 302/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7932 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5682e-04 - val_acc: 0.7979 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5682e-04
Epoch 303/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7967 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1002e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1002e-04
Epoch 304/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7932 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 0.0010 - val_acc: 0.8189 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 0.0010
Epoch 305/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7918 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.3006e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3006e-04
Epoch 306/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7833 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.9783e-04 - val_acc: 0.7944 - val_mean_absolute_error: 0.0226 - val_mean_squared_error: 9.9783e-04
Epoch 307/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7996 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5011e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5011e-04
Epoch 308/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7950 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.6793e-04 - val_acc: 0.8014 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6793e-04
Epoch 309/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7923 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.4372e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4372e-04
Epoch 310/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7959 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.6606e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6606e-04
Epoch 311/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7947 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.1064e-04 - val_acc: 0.7967 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 9.1064e-04
Epoch 312/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5953e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5953e-04
Epoch 313/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7877 - mean_absolute_error: 0.0250 - mean_squared_error: 0.0011 - val_loss: 9.8041e-04 - val_acc: 0.8049 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.8041e-04
Epoch 314/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7886 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5075e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5075e-04
Epoch 315/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7970 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.8311e-04 - val_acc: 0.8061 - val_mean_absolute_error: 0.0223 - val_mean_squared_error: 9.8311e-04
Epoch 316/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7900 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2457e-04 - val_acc: 0.8154 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.2457e-04
Epoch 317/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7772 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.5876e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5876e-04
Epoch 318/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7900 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.4438e-04 - val_acc: 0.8154 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4438e-04
Epoch 319/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7912 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.0178e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 9.0178e-04
Epoch 320/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7839 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2850e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2850e-04
Epoch 321/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.8023 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.3877e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3877e-04
Epoch 322/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7891 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.4772e-04 - val_acc: 0.7956 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4772e-04
Epoch 323/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.8008 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.3930e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3930e-04
Epoch 324/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7950 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.2355e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.2355e-04
Epoch 325/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 8.9909e-04 - val_acc: 0.8166 - val_mean_absolute_error: 0.0213 - val_mean_squared_error: 8.9909e-04
Epoch 326/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7818 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.8283e-04 - val_acc: 0.7932 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.8283e-04
Epoch 327/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7897 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.4351e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.4351e-04
Epoch 328/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7906 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1354e-04 - val_acc: 0.8178 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.1354e-04
Epoch 329/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7874 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.1441e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0215 - val_mean_squared_error: 9.1441e-04
Epoch 330/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7815 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.4464e-04 - val_acc: 0.8107 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.4464e-04
Epoch 331/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7932 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.6494e-04 - val_acc: 0.7745 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.6494e-04
Epoch 332/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7941 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.7334e-04 - val_acc: 0.7862 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7334e-04
Epoch 333/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7827 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.3706e-04 - val_acc: 0.7850 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.3706e-04
Epoch 334/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7926 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.7107e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.7107e-04
Epoch 335/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7961 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.0974e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.0974e-04
Epoch 336/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7932 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.1576e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1576e-04
Epoch 337/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7894 - mean_absolute_error: 0.0254 - mean_squared_error: 0.0012 - val_loss: 9.3497e-04 - val_acc: 0.8131 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.3497e-04
Epoch 338/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.8002 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.4368e-04 - val_acc: 0.8143 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.4368e-04
Epoch 339/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7833 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.6535e-04 - val_acc: 0.8037 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6535e-04
Epoch 340/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7856 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.1924e-04 - val_acc: 0.8259 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.1924e-04
Epoch 341/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7909 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5125e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.5125e-04
Epoch 342/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7935 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.2485e-04 - val_acc: 0.8026 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.2485e-04
Epoch 343/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7938 - mean_absolute_error: 0.0253 - mean_squared_error: 0.0012 - val_loss: 9.7670e-04 - val_acc: 0.7909 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7670e-04
Epoch 344/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7938 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.5178e-04 - val_acc: 0.8002 - val_mean_absolute_error: 0.0218 - val_mean_squared_error: 9.5178e-04
Epoch 345/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7953 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.7899e-04 - val_acc: 0.7979 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.7899e-04
Epoch 346/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7850 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.4088e-04 - val_acc: 0.8213 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.4088e-04
Epoch 347/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7897 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.5532e-04 - val_acc: 0.7991 - val_mean_absolute_error: 0.0219 - val_mean_squared_error: 9.5532e-04
Epoch 348/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7950 - mean_absolute_error: 0.0248 - mean_squared_error: 0.0011 - val_loss: 9.2023e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.2023e-04
Epoch 349/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.8008 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.3432e-04 - val_acc: 0.8084 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3432e-04
Epoch 350/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7961 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.3385e-04 - val_acc: 0.8096 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3385e-04
Epoch 351/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.8020 - mean_absolute_error: 0.0250 - mean_squared_error: 0.0011 - val_loss: 9.6222e-04 - val_acc: 0.7921 - val_mean_absolute_error: 0.0220 - val_mean_squared_error: 9.6222e-04
Epoch 352/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7935 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0012 - val_loss: 9.3054e-04 - val_acc: 0.8084 - val_mean_absolute_error: 0.0217 - val_mean_squared_error: 9.3054e-04
Epoch 353/400
3424/3424 [==============================] - 2s - loss: 0.0011 - acc: 0.7830 - mean_absolute_error: 0.0251 - mean_squared_error: 0.0011 - val_loss: 9.3375e-04 - val_acc: 0.8224 - val_mean_absolute_error: 0.0216 - val_mean_squared_error: 9.3375e-04
Epoch 354/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7935 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.6601e-04 - val_acc: 0.8072 - val_mean_absolute_error: 0.0221 - val_mean_squared_error: 9.6601e-04
Epoch 355/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7853 - mean_absolute_error: 0.0250 - mean_squared_error: 0.0012 - val_loss: 9.8808e-04 - val_acc: 0.8119 - val_mean_absolute_error: 0.0222 - val_mean_squared_error: 9.8808e-04
Epoch 356/400
3424/3424 [==============================] - 2s - loss: 0.0012 - acc: 0.7947 - mean_absolute_error: 0.0252 - mean_squared_error: 0.0012 - val_loss: 9.1900e-04 - val_acc: 0.8084 - val_mean_absolute_error: 0.0214 - val_mean_squared_error: 9.1900e-04
dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

Step 7: Visualize the Loss and Test Predictions

(IMPLEMENTATION) Answer a few questions and visualize the loss

Question 1: Outline the steps you took to get to your final neural network architecture and your reasoning at each step.

Answer:

First I started with the network architecture mentioned in the suggested article:

http://danielnouri.org/notes/2014/12/17/using-convolutional-neural-nets-to-detect-facial-keypoints-tutorial/

Its a pretty standard CNN architecture with ReLUs and layers of Convolution and Maxpooling doubling in size for several iterations.

To provide some parameter space for learning so many different x,y coords it seemed like a good idea to include multiple fully connected hidden layers. I changed 500 to 512 just to match the base 2 sizes of everything else.

The end is a fully connected layer with 30 outputs matching the required output and a default linear activation function.

After this I benchmarked several optimizers to see which might be the best for this problem.

It seems that the Adam family was the better choice, although the article suggested SGD + Nesterov as does the Stanford CS231n course.

The model seemed to perform okay so I decided to add dropout putting a 50% dropout on each layer of the network.

The test error and accuracy seems to leap to a point and not improve drastically so I figured it might be worth reducing the number of filters being used and removing one of the hidden fully connected layers.

I did this again by reducing the size of the fully connected hidden layer.

Now it appears to have more of a nice hockey stick curve on the loss graph, although the accuracy for test was leaping to 70% and flatlining which was concerning.

Perhaps it was getting stuck and unable to advance due to the high level of dropout?

Adding a more progressive dropout provided a nicer moving accuracy line.

I added a ReLU activation to the final hidden layer but the affect wasn't hugely apparently.

Then I figured the accuracy wasn't too bad at val_loss: 0.0033, val_acc: 0.6963 so it was time to look at adding some more data with data augmentation.

As discussed in the suggested article I flipped all the images and their key facial points and combined them with the original.

I did try randomizing the combined results but didn't see much affect.

Next I compared SGD + Nesterov and Adamax against 50 epochs with and without the new augmented data.

Adamax still beat SGD + Nesterov as previously and the augmented data provided for an improvement of nearly 7% which is huge, although it could simply be that more of the duplicated data appears in the testing set.

The error was reduced from val_loss: 0.0017 to val_loss: 0.0012.

I also thought it was worth trying Adam and was pleased to see that it was even better than Adamax.

Finally to see where the model can go I trained Adam with 400 epochs, early stopping at 150 epochs without change, and a model checkpointer.

Training stopped at 356 Epochs.

The best result was about: val_loss: 0.00091924 - val_acc: 0.8259.

The predictions are fairly good, although they could still be better in some cases. I think more unique data is required.

The network size and epochs is probably overkill for this accuracy and there is probably a smaller more light weight network which can achieve better more generalized results than this.

Given more time I would try to reduce it to the point where it suffers performance and build it back up from there.

Question 2: Defend your choice of optimizer. Which optimizers did you test, and how did you determine which worked best?

Answer:

The original article and the Stanford CS231n course both recommend SGD + Nesterov or Adam optimizers for CNN tasks.

For loss function because this is a regression task across 30 continuous x,y pair values rather than a Classification task across 30 discrete labels, it makes sense to use a loss function like mean squared error rather than something like categorical cross entropy.

A quick test of categorical cross entropy showed this in its terrible results.

For optimizers, I tested SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam and SGD + Nesterov.

Looking at the graph of results I chose to do the rest of my development on Adamax and then near the end compared SGD + Nesterov and Adam again to see if there was much difference.

In the end I chose Adam as the results were the best.

Use the code cell below to plot the training and validation loss of your neural network. You may find this resource useful.


In [64]:
## TODO: Visualize the training and validation loss of your neural network
show_history_graph(hist)


dict_keys(['val_loss', 'val_acc', 'val_mean_absolute_error', 'val_mean_squared_error', 'loss', 'acc', 'mean_absolute_error', 'mean_squared_error'])

Question 3: Do you notice any evidence of overfitting or underfitting in the above plot? If so, what steps have you taken to improve your model? Note that slight overfitting or underfitting will not hurt your chances of a successful submission, as long as you have attempted some solutions towards improving your model (such as regularization, dropout, increased/decreased number of layers, etc).

Answer:
In earlier iterations of the network without dropout it seemed as though there was issues gaining traction with the test accuracy. After reducing the layers and filters and adding progressively increasing dropout I managed to get a nice smooth hockey stick like curve that you can see above.

I would assume that there is some overfitting in the above model for several reasons, one the augmented data is probably leaking into the validation set in a way that prevents good generalization.

Visualize a Subset of the Test Predictions

Execute the code cell below to visualize your model's predicted keypoints on a subset of the testing images.


In [65]:
y_test = model14.predict(X_test)
fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(9):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    plot_data(X_test[i], y_test[i], ax)



Step 8: Complete the pipeline

With the work you did in Sections 1 and 2 of this notebook, along with your freshly trained facial keypoint detector, you can now complete the full pipeline. That is given a color image containing a person or persons you can now

  • Detect the faces in this image automatically using OpenCV
  • Predict the facial keypoints in each face detected in the image
  • Paint predicted keypoints on each face detected

In this Subsection you will do just this!

(IMPLEMENTATION) Facial Keypoints Detector

Use the OpenCV face detection functionality you built in previous Sections to expand the functionality of your keypoints detector to color images with arbitrary size. Your function should perform the following steps

  1. Accept a color image.
  2. Convert the image to grayscale.
  3. Detect and crop the face contained in the image.
  4. Locate the facial keypoints in the cropped image.
  5. Overlay the facial keypoints in the original (color, uncropped) image.

Note: step 4 can be the trickiest because remember your convolutional network is only trained to detect facial keypoints in $96 \times 96$ grayscale images where each pixel was normalized to lie in the interval $[0,1]$, and remember that each facial keypoint was normalized during training to the interval $[-1,1]$. This means - practically speaking - to paint detected keypoints onto a test face you need to perform this same pre-processing to your candidate face - that is after detecting it you should resize it to $96 \times 96$ and normalize its values before feeding it into your facial keypoint detector. To be shown correctly on the original image the output keypoints from your detector then need to be shifted and re-normalized from the interval $[-1,1]$ to the width and height of your detected face.

When complete you should be able to produce example images like the one below


In [66]:
from utils import *

# reload model
from keras.models import Sequential
from keras.layers import Convolution2D, MaxPooling2D, Dropout
from keras.layers import Flatten, Dense

final_model = Sequential()
final_model.add(Convolution2D(filters=16, kernel_size=(3, 3), activation='relu', input_shape=(96, 96, 1)))
final_model.add(MaxPooling2D(pool_size=(2, 2)))
final_model.add(Dropout(0.1))

final_model.add(Convolution2D(filters=32, kernel_size=(2, 2), activation='relu'))
final_model.add(MaxPooling2D(pool_size=(2, 2)))
final_model.add(Dropout(0.2))

final_model.add(Convolution2D(filters=64, kernel_size=(2, 2), activation='relu'))
final_model.add(MaxPooling2D(pool_size=(2, 2)))
final_model.add(Dropout(0.3))

final_model.add(Flatten())
final_model.add(Dense(256, activation='relu'))
final_model.add(Dropout(0.5))
final_model.add(Dense(30))

# Summarize the model
final_model.summary()

final_model_file = './model14_adam_long.hdf5'
final_model.load_weights(final_model_file)


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_52 (Conv2D)           (None, 94, 94, 16)        160       
_________________________________________________________________
max_pooling2d_52 (MaxPooling (None, 47, 47, 16)        0         
_________________________________________________________________
dropout_64 (Dropout)         (None, 47, 47, 16)        0         
_________________________________________________________________
conv2d_53 (Conv2D)           (None, 46, 46, 32)        2080      
_________________________________________________________________
max_pooling2d_53 (MaxPooling (None, 23, 23, 32)        0         
_________________________________________________________________
dropout_65 (Dropout)         (None, 23, 23, 32)        0         
_________________________________________________________________
conv2d_54 (Conv2D)           (None, 22, 22, 64)        8256      
_________________________________________________________________
max_pooling2d_54 (MaxPooling (None, 11, 11, 64)        0         
_________________________________________________________________
dropout_66 (Dropout)         (None, 11, 11, 64)        0         
_________________________________________________________________
flatten_18 (Flatten)         (None, 7744)              0         
_________________________________________________________________
dense_40 (Dense)             (None, 256)               1982720   
_________________________________________________________________
dropout_67 (Dropout)         (None, 256)               0         
_________________________________________________________________
dense_41 (Dense)             (None, 30)                7710      
=================================================================
Total params: 2,000,926
Trainable params: 2,000,926
Non-trainable params: 0
_________________________________________________________________

In [67]:
# Accept a color image.

# Load in color image for face detection
image = cv2.imread('images/obamas4.jpg')

# Convert the image to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

image_copy = np.copy(image)

# plot our image
fig = plt.figure(figsize = (9,9))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.set_title('image copy')
ax1.imshow(image_copy)


Out[67]:
<matplotlib.image.AxesImage at 0x7fd2e587b4e0>

In [68]:
### TODO: Use the face detection code we saw in Section 1 with your trained conv-net 
## TODO : Paint the predicted keypoints on the test image

# Convert the image to grayscale.
gray = cv2.cvtColor(image_copy, cv2.COLOR_RGB2GRAY)

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# Detect and crop the face contained in the image.
# Detect the faces in image
faces = face_cascade.detectMultiScale(gray, 1.25, 6)

# Print the number of faces detected in the image
print('Number of faces detected:', len(faces))

# Make a copy of the orginal image to draw face detections on
image_with_detections = np.copy(image)

# Get the bounding box for each detected face
for (x,y,w,h) in faces:
    # Add a red bounding box to the detections image
    cv2.rectangle(image_with_detections, (x,y), (x+w,y+h), (255,0,0), 3)
    

# Display the image with the detections
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

ax1.set_title('Image with Face Detections')
ax1.imshow(image_with_detections)


Number of faces detected: 2
Out[68]:
<matplotlib.image.AxesImage at 0x7fd2e5e78320>

In [69]:
# Locate the facial keypoints in the cropped image.
face_patches = []

for (x,y,w,h) in faces:
    face_patch = gray[y:y+h, x:x+w]
    face_patch = cv2.resize(face_patch, (96, 96))
    face_patch = np.expand_dims(face_patch, axis=2)
    face_patches.append(face_patch / 255)

fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(len(face_patches)):
    face = face_patches[i]
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    ax.set_title('Face patches in grayscale')
    ax.imshow(np.squeeze(face), cmap='gray') # plot the image



In [70]:
# Overlay the facial keypoints in the original (color, uncropped) image.
X_faces = np.asarray(face_patches)
y_faces = final_model.predict(X_faces)

fig = plt.figure(figsize=(20,20))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(len(faces)):
    ax = fig.add_subplot(3, 3, i + 1, xticks=[], yticks=[])
    ax.set_title('Face patches with keypoints')
    plot_data(X_faces[i], y_faces[i], ax)



In [71]:
fig = plt.figure(figsize = (9,9))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])

for i in range(len(faces)):
    x, y, w, h = faces[i]
    x_features = y_faces[i][0::2] * 48 + 48
    x_scaled = (x_features * w / 96) + x
    
    y_features = y_faces[i][1::2] * 48 + 48
    y_scaled = (y_features * h / 96) + y

    ax1.scatter(x_scaled, y_scaled, marker='.', c='w', s=20)
    
ax1.set_title('Original image with facial keypoints')
ax1.imshow(image)


Out[71]:
<matplotlib.image.AxesImage at 0x7fd2e6c92400>

In [72]:
import io

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

def keypoint_detection(image):

    gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.25, 6)

    # Make a copy of the orginal image to draw face detections on
    image_draw = np.copy(image)

    # Get the bounding box for each detected face
    for (x,y,w,h) in faces:
        # Add a red bounding box to the detections image
        cv2.rectangle(image_draw, (x,y), (x+w,y+h), (255,0,0), 3)
    
    # Locate the facial keypoints in the cropped image.
    face_patches = []

    for (x,y,w,h) in faces:
        face_patch = gray[y:y+h, x:x+w]
        face_patch = cv2.resize(face_patch, (96, 96))
        face_patch = np.expand_dims(face_patch, axis=2)
        face_patches.append(face_patch / 255)
    
    # Overlay the facial keypoints in the original (color, uncropped) image.
    X_faces = np.asarray(face_patches)
    y_faces = final_model.predict(X_faces)

    for i in range(len(faces)):
        x, y, w, h = faces[i]
        x_features = y_faces[i][0::2] * 48 + 48
        x_scaled = (x_features * w / 96) + x
        y_features = y_faces[i][1::2] * 48 + 48
        y_scaled = (y_features * h / 96) + y

        for x, y in zip(x_scaled, y_scaled):
            cv2.circle(image_draw, (x, y), 3, (0, 255, 0), -1)
    return image_draw

image = cv2.imread('images/obamas4.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
im = keypoint_detection(image)
print(f'Thanks Obama! 😂')
fig = plt.figure(figsize = (20,10))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.imshow(im)


Thanks Obama! 😂
Out[72]:
<matplotlib.image.AxesImage at 0x7fd2e6d69c50>

(Optional) Further Directions - add a filter using facial keypoints to your laptop camera

Now you can add facial keypoint detection to your laptop camera - as illustrated in the gif below.

The next Python cell contains the basic laptop video camera function used in the previous optional video exercises. Combine it with the functionality you developed for keypoint detection and marking in the previous exercise and you should be good to go!


In [73]:
import cv2
import time 
from keras.models import load_model
def laptop_camera_go():
    # Create instance of video capturer
    cv2.namedWindow("face detection activated")
    vc = cv2.VideoCapture(0)

    # Try to get the first frame
    if vc.isOpened(): 
        rval, frame = vc.read()
    else:
        rval = False
    
    # keep video stream open
    while rval:
        # plot image from camera with detections marked
        keypoint_frame = keypoint_detection(frame)
        cv2.imshow("face detection activated", keypoint_frame)
        
        # exit functionality - press any key to exit laptop video
        key = cv2.waitKey(20)
        if key > 0: # exit by pressing any key
            # destroy windows
            cv2.destroyAllWindows()
            
            # hack from stack overflow for making sure window closes on osx --> https://stackoverflow.com/questions/6116564/destroywindow-does-not-close-window-on-mac-using-python-and-opencv
            for i in range (1,5):
                cv2.waitKey(1)
            return
        
        # read next frame
        time.sleep(0.05)             # control framerate for computation - default 20 frames per sec
        rval, frame = vc.read()

In [74]:
# Run your keypoint face painter   
# laptop_camera_go()

Keypoint Fun 😁

(Optional) Further Directions - add a filter using facial keypoints

Using your freshly minted facial keypoint detector pipeline you can now do things like add fun filters to a person's face automatically. In this optional exercise you can play around with adding sunglasses automatically to each individual's face in an image as shown in a demonstration image below.

To produce this effect an image of a pair of sunglasses shown in the Python cell below.


In [75]:
# Load in sunglasses image - note the usage of the special option
# cv2.IMREAD_UNCHANGED, this option is used because the sunglasses 
# image has a 4th channel that allows us to control how transparent each pixel in the image is
sunglasses = cv2.imread("images/sunglasses_4.png", cv2.IMREAD_UNCHANGED)

# Plot the image
fig = plt.figure(figsize = (6,6))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.imshow(sunglasses)
ax1.axis('off');


This image is placed over each individual's face using the detected eye points to determine the location of the sunglasses, and eyebrow points to determine the size that the sunglasses should be for each person (one could also use the nose point to determine this).

Notice that this image actually has 4 channels, not just 3.


In [76]:
# Print out the shape of the sunglasses image
print ('The sunglasses image has shape: ' + str(np.shape(sunglasses)))


The sunglasses image has shape: (1123, 3064, 4)

It has the usual red, blue, and green channels any color image has, with the 4th channel representing the transparency level of each pixel in the image. Here's how the transparency channel works: the lower the value, the more transparent the pixel will become. The lower bound (completely transparent) is zero here, so any pixels set to 0 will not be seen.

This is how we can place this image of sunglasses on someone's face and still see the area around of their face where the sunglasses lie - because these pixels in the sunglasses image have been made completely transparent.

Lets check out the alpha channel of our sunglasses image in the next Python cell. Note because many of the pixels near the boundary are transparent we'll need to explicitly print out non-zero values if we want to see them.


In [77]:
# Print out the sunglasses transparency (alpha) channel
alpha_channel = sunglasses[:,:,3]
print ('the alpha channel here looks like')
print (alpha_channel)

# Just to double check that there are indeed non-zero values
# Let's find and print out every value greater than zero
values = np.where(alpha_channel != 0)
print ('\n the non-zero values of the alpha channel look like')
print (values)


the alpha channel here looks like
[[0 0 0 ..., 0 0 0]
 [0 0 0 ..., 0 0 0]
 [0 0 0 ..., 0 0 0]
 ..., 
 [0 0 0 ..., 0 0 0]
 [0 0 0 ..., 0 0 0]
 [0 0 0 ..., 0 0 0]]

 the non-zero values of the alpha channel look like
(array([  17,   17,   17, ..., 1109, 1109, 1109]), array([ 687,  688,  689, ..., 2376, 2377, 2378]))

This means that when we place this sunglasses image on top of another image, we can use the transparency channel as a filter to tell us which pixels to overlay on a new image (only the non-transparent ones with values greater than zero).

One last thing: it's helpful to understand which keypoint belongs to the eyes, mouth, etc. So, in the image below, we also display the index of each facial keypoint directly on the image so that you can tell which keypoints are for the eyes, eyebrows, etc.

With this information, you're well on your way to completing this filtering task! See if you can place the sunglasses automatically on the individuals in the image loaded in / shown in the next Python cell.


In [78]:
# Load in color image for face detection
image = cv2.imread('images/obamas4.jpg')

# Convert the image to RGB colorspace
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)


# Plot the image
fig = plt.figure(figsize = (8,8))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.set_title('Original Image')
ax1.imshow(image)


Out[78]:
<matplotlib.image.AxesImage at 0x7fd2f1d17400>

In [79]:
## (Optional) TODO: Use the face detection code we saw in Section 1 with your trained conv-net to put
## sunglasses on the individuals in our test image

# Extract the pre-trained face detector from an xml file
face_cascade = cv2.CascadeClassifier('detector_architectures/haarcascade_frontalface_default.xml')

# https://stackoverflow.com/questions/40895785/using-opencv-to-overlay-transparent-image-onto-another-image

def blend_transparent(face_img, overlay_t_img):
    # Split out the transparency mask from the colour info
    overlay_img = overlay_t_img[:,:,:3] # Grab the BRG planes
    overlay_mask = overlay_t_img[:,:,3:]  # And the alpha plane

    # Again calculate the inverse mask
    background_mask = 255 - overlay_mask

    # Turn the masks into three channel, so we can use them as weights
    overlay_mask = cv2.cvtColor(overlay_mask, cv2.COLOR_GRAY2BGR)
    background_mask = cv2.cvtColor(background_mask, cv2.COLOR_GRAY2BGR)

    # Create a masked out face image, and masked out overlay
    # We convert the images to floating point in range 0.0 - 1.0
    face_part = (face_img * (1 / 255.0)) * (background_mask * (1 / 255.0))
    overlay_part = (overlay_img * (1 / 255.0)) * (overlay_mask * (1 / 255.0))

    # And finally just add them together, and rescale it back to an 8bit integer image    
    return np.uint8(cv2.addWeighted(face_part, 255.0, overlay_part, 255.0, 0.0))

feature_mapping = {}
feature_mapping[1] = 'eye_right'
feature_mapping[2] = 'eye_left'
feature_mapping[3] = 'inner_eye_right'
feature_mapping[4] = 'outer_eye_right'
feature_mapping[5] = 'inner_eye_left'
feature_mapping[6] = 'outer_eye_left'
feature_mapping[7] = 'inner_eyebrow_right'
feature_mapping[8] = 'outer_eyebrow_right'
feature_mapping[9] = 'inner_eyebrow_left'
feature_mapping[10] = 'outer_eyebrow_left'
feature_mapping[11] = 'nose'
feature_mapping[12] = 'mouth_right'
feature_mapping[13] = 'mouth_left'
feature_mapping[14] = 'mouth_top'
feature_mapping[15] = 'mouth_bottom'

def add_overlay(image, overlays):
    gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.25, 6)

    # Make a copy of the orginal image to draw face detections on
    image_draw = np.copy(image)

    # Get the bounding box for each detected face
    #     for (x,y,w,h) in faces:
    #         # Add a red bounding box to the detections image
    #         cv2.rectangle(image_draw, (x,y), (x+w,y+h), (255,0,0), 3)
    
    # Locate the facial keypoints in the cropped image.
    face_patches = []

    for (x,y,w,h) in faces:
        face_patch = gray[y:y+h, x:x+w]
        face_patch = cv2.resize(face_patch, (96, 96))
        face_patch = np.expand_dims(face_patch, axis=2)
        face_patches.append(face_patch / 255)
    
    # Overlay the facial keypoints in the original (color, uncropped) image.
    X_faces = np.asarray(face_patches)
    y_faces = final_model.predict(X_faces)

    face_features = []
    for i in range(len(faces)):
        x, y, w, h = faces[i]
        x_features = y_faces[i][0::2] * 48 + 48
        x_scaled = (x_features * w / 96) + x
        y_features = y_faces[i][1::2] * 48 + 48
        y_scaled = (y_features * h / 96) + y

        count = 0
        features = {}
        for x, y in zip(x_scaled, y_scaled):
            count += 1
            if count in feature_mapping:
                name = feature_mapping[count]
                features[name] = (x, y)
        face_features.append(features)

    for overlay in overlays:
        for features in face_features:
            image_draw = overlay(image_draw, features)
    return image_draw


def glasses(overlay):
    def apply(image, features):
        padding_ratio = 1.3 # glasses need to be bigger than facial points
        l = features['outer_eyebrow_left']
        r = features['outer_eyebrow_right']

        overlay_height = overlay.shape[0]
        overlay_width = overlay.shape[1]

        # calculate width based on eyebrow distance
        width = int(r[0] - l[0])
        scaled_width = int(width * padding_ratio)
        width_diff = scaled_width - width 

        # calculate height based on ratio
        ratio = overlay_width / width
        height = int(overlay_height / ratio)
        scaled_height = int(height * padding_ratio)
        height_diff = scaled_height - height

        # scale overlay to match eyebrow distance * padding ratio
        overlay_resize = cv2.resize(overlay, (scaled_width, scaled_height))
        ly = int(l[1] - (height_diff / 2))
        lx = int(l[0] - (width_diff / 2))

        foreground = overlay_resize
        background = image[ly:ly+scaled_height, lx:lx+scaled_width]
        composite = blend_transparent(background, foreground)

        image[ly:ly+scaled_height, lx:lx+scaled_width] = composite[:, :, :3]
        return image
    return apply

def cigarette(overlay):
    def apply(image, features):
        padding_ratio = 1 # glasses need to be bigger than facial points
        l = features['outer_eyebrow_left']
        r = features['outer_eyebrow_right']
        ml = features['mouth_left']

        overlay_height = overlay.shape[0]
        overlay_width = overlay.shape[1]

        # calculate width based on eyebrow distance
        width = int(r[0] - l[0])
        scaled_width = int(width * padding_ratio)
        width_diff = scaled_width - width 

        # calculate height based on ratio
        ratio = overlay_width / width
        height = int(overlay_height / ratio)
        scaled_height = int(height * padding_ratio)
        height_diff = scaled_height - height 

        # scale overlay to match eyebrow distance * padding ratio
        overlay_resize = cv2.resize(overlay, (scaled_width, scaled_height))

        ly = int(ml[1] - (scaled_height * 0.5))
        lx = int(ml[0] - (scaled_width * 0.85))

        foreground = overlay_resize
        background = image[ly:ly+scaled_height, lx:lx+scaled_width]
        composite = blend_transparent(background, foreground)
        image[ly:ly+scaled_height, lx:lx+scaled_width] = composite[:, :, :3]
        return image
    return apply

def hat(overlay):
    def apply(image, features):
        padding_ratio = 2.0 # glasses need to be bigger than facial points
        l = features['outer_eyebrow_left']
        r = features['outer_eyebrow_right']
        er = features['eye_right']
        n = features['nose']

        overlay_height = overlay.shape[0]
        overlay_width = overlay.shape[1]

        # calculate width based on eyebrow distance
        width = int(r[0] - l[0])
        scaled_width = int(width * padding_ratio)
        width_diff = scaled_width - width 

        # calculate height based on ratio
        ratio = overlay_width / width
        height = int(overlay_height / ratio)
        scaled_height = int(height * padding_ratio)
        height_diff = scaled_height - height 

        # scale overlay to match eyebrow distance * padding ratio
        overlay_resize = cv2.resize(overlay, (scaled_width, scaled_height))

        eye_nose_distance = n[1] - er[1]
        ly = int(l[1] - (eye_nose_distance * 4))
        lx = int(l[0] - (width_diff / 2))

        foreground = overlay_resize
        if ly < 0:
            scaled_height = scaled_height + ly
            foreground = foreground[abs(ly):, :, :]
            ly = 0
        background = image[ly:ly+scaled_height, lx:lx+scaled_width]
        composite = blend_transparent(background, foreground)
        image[ly:ly+scaled_height, lx:lx+scaled_width] = composite[:, :, :3]
        return image
    return apply

In [80]:
# The ex-Australian Prime Minister at his best!

What about these sick sunnies?


In [81]:
def rgba2bgra(image):
    sub = Image.fromarray(image)
    sub = sub.convert("RGBA")
    data = np.array(sub)
    red, green, blue, alpha = data.T
    data = np.array([blue, green, red, alpha])
    data = data.transpose()
    return data

image = cv2.imread('images/obamas4.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

oakleys = cv2.imread("images/oakleys.png", cv2.IMREAD_UNCHANGED)
oakleys = rgba2bgra(oakleys)
cig = cv2.imread("images/cigarette.png", cv2.IMREAD_UNCHANGED)
cig = rgba2bgra(cig)
swag = cv2.imread("images/hat.png", cv2.IMREAD_UNCHANGED)
swag = rgba2bgra(swag)

image = add_overlay(image, [hat(swag), glasses(oakleys), cigarette(cig)])

fig = plt.figure(figsize = (20,10))
ax1 = fig.add_subplot(111)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.imshow(image)

print('Move over Tony theres a new Dealer in town 😭')


Move over Tony theres a new Dealer in town 😭

(Optional) Further Directions - add a filter using facial keypoints to your laptop camera

Now you can add the sunglasses filter to your laptop camera - as illustrated in the gif below.

The next Python cell contains the basic laptop video camera function used in the previous optional video exercises. Combine it with the functionality you developed for adding sunglasses to someone's face in the previous optional exercise and you should be good to go!


In [82]:
import cv2
import time 
from keras.models import load_model
import numpy as np

def laptop_camera_go():
    # Create instance of video capturer
    cv2.namedWindow("face detection activated")
    vc = cv2.VideoCapture(0)

    # try to get the first frame
    if vc.isOpened(): 
        rval, frame = vc.read()
    else:
        rval = False
    
    # Keep video stream open
    while rval:
        # Plot image from camera with detections marked
        overlay_frame = add_overlay(frame, [glasses(oakleys)])
        cv2.imshow("face detection activated", overlay_frame)
        
        # Exit functionality - press any key to exit laptop video
        key = cv2.waitKey(20)
        if key > 0: # exit by pressing any key
            # Destroy windows 
            cv2.destroyAllWindows()
            
            for i in range (1,5):
                cv2.waitKey(1)
            return
        
        # Read next frame
        time.sleep(0.05)             # control framerate for computation - default 20 frames per sec
        rval, frame = vc.read()

In [83]:
# Run sunglasses painter
# laptop_camera_go()

ZOMG LOL!