AI for Mechanical Engineering: Dynamics


By Keonhyeok Park
http://iailab.kaist.ac.kr/
Industrial AI Lab at KAIST
In [ ]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.preprocessing.sequence import pad_sequences
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Input, RepeatVector

import os

1. Projectile Motion (Trajectory Prediction)¶

Explanation of Equations Used¶

When solving the projectile motion with air resistance, several key equations and principles are used to model the motion accurately. Below are the detailed descriptions of these equations:

Decomposing Initial Velocity¶

The initial velocity $v_0$ is decomposed into horizontal ($ v_{x0} $) and vertical ($ v_{y0} $) components based on the launch angle $ \theta $:


$$v_{x0} = v_0 cos(\theta)$$

$$v_{y0} = v_0 sin(\theta)$$


Air Resistance (Drag Force)¶

The drag force $ F_d $ acting on the projectile is given by Newton's drag law, which states that the drag force is proportional to the square of the velocity. The drag force can be calculated as:


$$F_d = \frac{1}{2} C_d \rho A v^2$$


where:

  • $ C_d $ is the drag coefficient
  • $ \rho $ is the air density
  • $ A $ is the cross-sectional area of the projectile
  • $ v $ is the instantaneous velocity of the projectile

Acceleration Components¶

The horizontal ($ a_x $) and vertical ($ a_y $) components of acceleration due to drag and gravity are given by:


$$\begin{align*} a_x &= -\frac{F_d}{m} \cdot \frac{v_x}{v} \\ a_y &= -g - \frac{F_d}{m} \cdot \frac{v_y}{v} \end{align*}$$


where:

  • $ g $ is the acceleration due to gravity (9.81 m/s²)
  • $ m $ is the mass of the projectile
  • $ v_x $ and $ v_y $ are the horizontal and vertical components of the velocity, respectively

Solving Differential Equations¶

The projectile motion is governed by the second-order differential equations derived from Newton's second law. These equations are solved numerically using the odeint function from the scipy library. The state vector $[x, y, v_x, v_y]$ is updated at each time step.


Stopping Condition¶

The simulation time is defined as a range from 0 to a maximum time, divided into a number of time steps (e.g., 10,000). The simulation stops when the vertical position ($ y $) becomes less than or equal to zero, indicating the projectile has hit the ground. The index where this occurs is found and the data up to this point is retained:


$$ \text{ground_hit_index} = \text{np.where}(y < 0)[0][0] $$


By using these equations and principles, we can model the trajectory of a projectile under the influence of gravity and air resistance, providing a realistic simulation of its motion.

In [ ]:
def projectile_derivatives(state, t, mass, drag_coefficient, area, air_density):
    x, y, vx, vy = state

    # Calculate speed
    v = np.sqrt(vx**2 + vy**2)

    # Calculate drag force
    Fd = 0.5 * drag_coefficient * air_density * area * v**2

    # Calculate acceleration
    ax = -Fd * (vx / v) / mass
    ay = -9.81 - (Fd * (vy / v) / mass)

    return [vx, vy, ax, ay]

def projectile_trajectory(v0, theta, mass, drag_coefficient, area, air_density, num_points=1000):
    theta_rad = np.radians(theta)  # Convert angle to radians
    vx0 = v0 * np.cos(theta_rad)  # Initial velocity in x-direction
    vy0 = v0 * np.sin(theta_rad)  # Initial velocity in y-direction

    # Initial state: [x, y, vx, vy]
    initial_state = [0, 0, vx0, vy0]

    # Time parameters
    dt = 0.01  # Time step in seconds
    t = 0  # Initial time

    # Lists to store trajectory points
    x_points = []
    y_points = []

    # Initial state
    state = initial_state

    # Simulation loop
    while state[1] >= 0:
        # Append current position to trajectory
        x_points.append(state[0])
        y_points.append(state[1])

        # Compute derivatives
        derivatives = projectile_derivatives(state, t, mass, drag_coefficient, area, air_density)

        # Update state using Euler's method
        state = [state[i] + dt * derivatives[i] for i in range(4)]

        # Update time
        t += dt

    # Convert lists to numpy arrays
    x_points = np.array(x_points)
    y_points = np.array(y_points)

    # Interpolate to get fixed number of points
    distance = np.linspace(0, x_points[-1], num_points)
    y_interpolated = np.interp(distance, x_points, y_points)

    return distance, y_interpolated

v0 = 1000  # Initial speed in m/s
theta = 80  # Launch angle in degrees
mass = 0.145  # Mass of the projectile in kg (e.g., a baseball)
drag_coefficient = 0.47  # Drag coefficient (typical for a sphere)
area = 0.0042  # Cross-sectional area in m^2 (typical for a baseball)
air_density = 1.225  # Air density in kg/m^3 (at sea level)

x, y = projectile_trajectory(v0, theta, mass, drag_coefficient, area, air_density)

# Plotting the trajectory
plt.figure(figsize=(10, 10))
plt.subplot(211)
plt.plot(x, y, '.')
plt.title("Projectile Trajectory with Air Resistance (sampling)")
plt.xlabel("Distance (m)")
plt.ylabel("Height (m)")
plt.grid(True)
plt.subplot(212)
plt.plot(x, y)
plt.title("Projectile Trajectory with Air Resistance")
plt.xlabel("Distance (m)")
plt.ylabel("Height (m)")
plt.grid(True)
plt.show()
No description has been provided for this image

Lab 1: Projectile Motion with Air Resistance¶

  • Input: Initial angle ($\theta$), initial velocity ($v$)
  • Output: Trajectory

Projectile Data Generation¶

  • 1,000 dataset
  • Angles: 10 to 80 degrees
  • Velocities: 50 to 1000 m/s
In [ ]:
def generate_projectile_data(n_samples=1000):
    angles = np.linspace(10, 80, n_samples)
    velocities = np.linspace(50, 1000, n_samples)

    data = []

    for v0, theta in zip(velocities, angles):
        x, y = projectile_trajectory(v0, theta, mass, drag_coefficient, area, air_density)
        trajectory = np.vstack((x, y)).T
        data.append((v0, theta, trajectory))

    return data

data = generate_projectile_data()
In [ ]:
random_idx = np.array([0,100,500])
plt.figure(figsize = (15,8))
plt.title('Velocity: {:.2f} / {:.2f} / {:.2f}\nAngle: {:.2f} / {:.2f} / {:.2f}'.format(data[random_idx[0]][0],data[random_idx[1]][0],data[random_idx[2]][0],
                                                                  data[random_idx[0]][1],data[random_idx[1]][1],data[random_idx[2]][1]),
         fontsize=20)
for idx in random_idx:
    plt.plot(data[idx][2][:,0],data[idx][2][:,1], label = idx, linewidth=3, linestyle='-')
plt.legend(title='Random Index',title_fontsize = 15, fontsize = 15)
Out[ ]:
<matplotlib.legend.Legend at 0x7c0712d45780>
No description has been provided for this image
  • Preprocess the dataset
In [ ]:
def preprocess_data(data):
    max_len = max(len(traj[2]) for traj in data)

    X = []
    y = []

    for v0, theta, trajectory in data:
        input_features = np.array([v0, theta])
        trajectory = np.array(trajectory)
        X.append(input_features)  # Repeat input features to match trajectory length
        y.append(trajectory)

    X = np.array(X)
    y = np.array(y)

    input_scaler = MinMaxScaler(feature_range=(0, 1))
    output_scaler = MinMaxScaler(feature_range=(0, 1))

    # Flatten the input and output arrays for scaling
    X_flattened = X.reshape(-1, X.shape[-1])
    y_flattened = y.reshape(-1, y.shape[-1])

    # Fit and transform the scalers
    X_scaled_flattened = input_scaler.fit_transform(X_flattened)
    y_scaled_flattened = output_scaler.fit_transform(y_flattened)

    # Reshape back to the original shape
    X_scaled = X_scaled_flattened.reshape(X.shape)
    y_scaled = y_scaled_flattened.reshape(y.shape)

    return X_scaled, y_scaled, input_scaler, output_scaler

X_scaled, y_scaled, input_scaler, output_scaler = preprocess_data(data)
# Display shapes to verify
print("X_scaled shape:", X_scaled.shape)
print("y_scaled shape:", y_scaled.shape)
X_scaled shape: (1000, 2)
y_scaled shape: (1000, 1000, 2)

LSTM Model Architecture¶

In [ ]:
model = Sequential()
model.add(Dense(128, activation='relu', input_shape=(2,)))  # (batch_size, 2) -> (batch_size, 128)
model.add(RepeatVector(y_scaled.shape[1])) # (batch_size, 1000, 128)
model.add(LSTM(128, return_sequences=True)) # (batch_size, 1000, 128)
model.add(Dense(2))  # (batch_size, 1000, 2) == (batch_size, timesteps, features)

# Model compile
model.compile(optimizer='adam', loss='mse')
model.summary()
Model: "sequential"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 dense (Dense)               (None, 128)               384       
                                                                 
 repeat_vector (RepeatVecto  (None, 1000, 128)         0         
 r)                                                              
                                                                 
 lstm (LSTM)                 (None, 1000, 128)         131584    
                                                                 
 dense_1 (Dense)             (None, 1000, 2)           258       
                                                                 
=================================================================
Total params: 132226 (516.51 KB)
Trainable params: 132226 (516.51 KB)
Non-trainable params: 0 (0.00 Byte)
_________________________________________________________________
In [ ]:
history = model.fit(X_scaled, y_scaled, epochs=50, batch_size=32, validation_split=0.2)
Epoch 1/50
25/25 [==============================] - 11s 137ms/step - loss: 0.0612 - val_loss: 0.1298
Epoch 2/50
25/25 [==============================] - 2s 93ms/step - loss: 0.0439 - val_loss: 0.0590
Epoch 3/50
25/25 [==============================] - 2s 72ms/step - loss: 0.0421 - val_loss: 0.0679
Epoch 4/50
25/25 [==============================] - 2s 60ms/step - loss: 0.0411 - val_loss: 0.0549
Epoch 5/50
25/25 [==============================] - 1s 54ms/step - loss: 0.0423 - val_loss: 0.0759
Epoch 6/50
25/25 [==============================] - 2s 63ms/step - loss: 0.0430 - val_loss: 0.0638
Epoch 7/50
25/25 [==============================] - 2s 63ms/step - loss: 0.0396 - val_loss: 0.0548
Epoch 8/50
25/25 [==============================] - 1s 40ms/step - loss: 0.0389 - val_loss: 0.0520
Epoch 9/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0380 - val_loss: 0.0512
Epoch 10/50
25/25 [==============================] - 1s 42ms/step - loss: 0.0416 - val_loss: 0.0582
Epoch 11/50
25/25 [==============================] - 1s 45ms/step - loss: 0.0386 - val_loss: 0.0527
Epoch 12/50
25/25 [==============================] - 1s 47ms/step - loss: 0.0370 - val_loss: 0.0519
Epoch 13/50
25/25 [==============================] - 1s 35ms/step - loss: 0.0355 - val_loss: 0.0515
Epoch 14/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0461 - val_loss: 0.0611
Epoch 15/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0419 - val_loss: 0.0577
Epoch 16/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0402 - val_loss: 0.0518
Epoch 17/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0384 - val_loss: 0.0502
Epoch 18/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0373 - val_loss: 0.0501
Epoch 19/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0448 - val_loss: 0.0638
Epoch 20/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0368 - val_loss: 0.0565
Epoch 21/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0369 - val_loss: 0.0480
Epoch 22/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0386 - val_loss: 0.0551
Epoch 23/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0390 - val_loss: 0.0644
Epoch 24/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0364 - val_loss: 0.0515
Epoch 25/50
25/25 [==============================] - 1s 45ms/step - loss: 0.0349 - val_loss: 0.0608
Epoch 26/50
25/25 [==============================] - 1s 46ms/step - loss: 0.0385 - val_loss: 0.0525
Epoch 27/50
25/25 [==============================] - 1s 41ms/step - loss: 0.0409 - val_loss: 0.0562
Epoch 28/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0470 - val_loss: 0.0517
Epoch 29/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0398 - val_loss: 0.0505
Epoch 30/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0383 - val_loss: 0.0471
Epoch 31/50
25/25 [==============================] - 1s 35ms/step - loss: 0.0381 - val_loss: 0.0448
Epoch 32/50
25/25 [==============================] - 1s 44ms/step - loss: 0.0368 - val_loss: 0.0595
Epoch 33/50
25/25 [==============================] - 1s 45ms/step - loss: 0.0397 - val_loss: 0.0518
Epoch 34/50
25/25 [==============================] - 1s 47ms/step - loss: 0.0377 - val_loss: 0.0519
Epoch 35/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0353 - val_loss: 0.0499
Epoch 36/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0434 - val_loss: 0.0757
Epoch 37/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0406 - val_loss: 0.0706
Epoch 38/50
25/25 [==============================] - 1s 42ms/step - loss: 0.0399 - val_loss: 0.0997
Epoch 39/50
25/25 [==============================] - 1s 44ms/step - loss: 0.0444 - val_loss: 0.0607
Epoch 40/50
25/25 [==============================] - 1s 47ms/step - loss: 0.0412 - val_loss: 0.0589
Epoch 41/50
25/25 [==============================] - 1s 35ms/step - loss: 0.0410 - val_loss: 0.0483
Epoch 42/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0384 - val_loss: 0.0903
Epoch 43/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0381 - val_loss: 0.0760
Epoch 44/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0374 - val_loss: 0.0830
Epoch 45/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0467 - val_loss: 0.0756
Epoch 46/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0410 - val_loss: 0.0714
Epoch 47/50
25/25 [==============================] - 1s 33ms/step - loss: 0.0394 - val_loss: 0.0646
Epoch 48/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0381 - val_loss: 0.0613
Epoch 49/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0362 - val_loss: 0.0517
Epoch 50/50
25/25 [==============================] - 1s 34ms/step - loss: 0.0327 - val_loss: 0.1777
In [ ]:
plt.plot(history.history['loss'], label='train loss')
plt.plot(history.history['val_loss'], label='val loss')
plt.legend()
plt.show()
No description has been provided for this image
In [ ]:
v0_test = 300
theta_test = 45

input_features = np.array([v0_test, theta_test]).reshape(1, -1)
input_scaled = input_scaler.transform(input_features)
prediction_scaled = model.predict(input_scaled)
predicted_trajectory = output_scaler.inverse_transform(prediction_scaled.reshape(-1, 2))

true_distance, true_height = projectile_trajectory(v0_test, theta_test, mass, drag_coefficient, area, air_density)


plt.plot(predicted_trajectory[:, 0], predicted_trajectory[:, 1], label='Predicted Trajectory')


plt.plot(true_distance, true_height, label='True Trajectory', linestyle='dashed')

plt.xlabel('Distance (m)')
plt.ylabel('Height (m)')
plt.title('Predicted vs True Projectile Trajectory')
plt.legend()
plt.show()
1/1 [==============================] - 0s 400ms/step
No description has been provided for this image

Ineffective Cases¶

  • Input: Initial angles, initial velocities
  • Output: Trajectory

[Reasons for Ineffectiveness]

  • Predicting multiple future time points based only on the current state may lead to insufficient information, especially when the model needs to learn nonlinearities and complex interactions.
  • Long-term predictions based solely on initial conditions are very challenging. Small prediction errors can accumulate over time, leading to significant inaccuracies.

Lab 2: Projectile Motion with Air Resistance¶

  • Input: Partial Trajectory (10 timesteps)
  • Output: Next Position (1 timestep)

Data Generation¶

In [ ]:
def projectile_trajectory(v0, theta, mass, drag_coefficient, area, air_density, num_points=100):
    theta_rad = np.radians(theta)  # Convert angle to radians
    vx0 = v0 * np.cos(theta_rad)  # Initial velocity in x-direction
    vy0 = v0 * np.sin(theta_rad)  # Initial velocity in y-direction

    # Initial state: [x, y, vx, vy]
    initial_state = [0, 0, vx0, vy0]

    # Time parameters
    dt = 0.01  # Time step in seconds
    t = 0  # Initial time

    # Lists to store trajectory points
    x_points = []
    y_points = []


    # Initial state
    state = initial_state

    # Simulation loop
    while state[1] >= 0:
        # Append current position to trajectory
        x_points.append(state[0])
        y_points.append(state[1])

        # Compute derivatives
        derivatives = projectile_derivatives(state, t, mass, drag_coefficient, area, air_density)

        # Update state using Euler's method
        state = [state[i] + dt * derivatives[i] for i in range(4)]

        # Update time
        t += dt

    # Convert lists to numpy arrays
    x_points = np.array(x_points)
    y_points = np.array(y_points)

    # Interpolate to get fixed number of points
    distance = np.linspace(0, x_points[-1], num_points)
    y_interpolated = np.interp(distance, x_points, y_points)
    return distance, y_interpolated
In [ ]:
train_window = 10

def create_inout_sequences(input_data, tw):
    inout_seq = []
    L = len(input_data)
    for i in range(90):
        train_seq = input_data[i:i+tw]
        train_label = input_data[i+tw:i+tw+1]
        inout_seq.append((train_seq ,train_label))
    return inout_seq

def make_inout_seq(angle, speed):
    X, Y = projectile_trajectory(speed, angle, mass, drag_coefficient, area, air_density)
    x = np.zeros((len(X), 2))
    for i in range(len(X)):
        x[i, 0] = X[i]
        x[i, 1] = Y[i]
    scaler = MinMaxScaler(feature_range=(0, 1))
    train_data_normalized = scaler.fit_transform(x.reshape(-1, 2))
    train_window = 10
    train_inout_seq = create_inout_sequences(train_data_normalized.reshape(len(X), 2), train_window)
    return scaler, train_inout_seq

scaler, train_inout_seq = make_inout_seq(15, 500)
In [ ]:
X_train = np.array([seq[0] for seq in train_inout_seq])
y_train = np.array([seq[1] for seq in train_inout_seq]).squeeze()
print(X_train.shape, y_train.shape)
(90, 10, 2) (90, 2)
In [ ]:
plt.figure(figsize=(12,5))
for i in range(15):
    scaler_test, test_inout_seq = make_inout_seq(5*i, 500)
    X_test = np.array([seq[0] for seq in test_inout_seq])
    y_test = np.array([seq[1] for seq in test_inout_seq])

    X_test_traj = scaler_test.inverse_transform(X_test[0].reshape(-1,2))
    y_test_traj = scaler_test.inverse_transform(y_test.reshape(-1,2))
    plt.plot(X_test_traj[:,0], X_test_traj[:,1])
    plt.plot(y_test_traj[:,0], y_test_traj[:,1], label = 'actual', color = 'blue')

handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
plt.legend(by_label.values(), by_label.keys(), fontsize = 15)
plt.xlim([0,400])
plt.ylim([0,300])
plt.title("Projectile Trajectory with Air Resistance", fontsize = 15)
plt.xlabel("Distance (m)", fontsize = 15)
plt.ylabel("Height (m)", fontsize = 15)
Out[ ]:
Text(0, 0.5, 'Height (m)')
No description has been provided for this image

LSTM Model Architecture¶

In [ ]:
# Build LSTM model with Keras
model = Sequential()
model.add(LSTM(100, input_shape=(train_window, 2), return_sequences=True))
model.add(LSTM(100))
model.add(Dense(100))
model.add(Dense(2))

model.compile(optimizer='adam', loss='mse')
model.summary()
Model: "sequential_1"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 lstm_1 (LSTM)               (None, 10, 100)           41200     
                                                                 
 lstm_2 (LSTM)               (None, 100)               80400     
                                                                 
 dense_2 (Dense)             (None, 100)               10100     
                                                                 
 dense_3 (Dense)             (None, 2)                 202       
                                                                 
=================================================================
Total params: 131902 (515.24 KB)
Trainable params: 131902 (515.24 KB)
Non-trainable params: 0 (0.00 Byte)
_________________________________________________________________
In [ ]:
history = model.fit(X_train, y_train, epochs=400, batch_size=32)
Epoch 1/400
3/3 [==============================] - 4s 10ms/step - loss: 0.2754
Epoch 2/400
3/3 [==============================] - 0s 8ms/step - loss: 0.0457
Epoch 3/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0700
Epoch 4/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0224
Epoch 5/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0375
Epoch 6/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0283
Epoch 7/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0095
Epoch 8/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0122
Epoch 9/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0089
Epoch 10/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0027
Epoch 11/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0056
Epoch 12/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0048
Epoch 13/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0017
Epoch 14/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0022
Epoch 15/400
3/3 [==============================] - 0s 7ms/step - loss: 0.0017
Epoch 16/400
3/3 [==============================] - 0s 8ms/step - loss: 7.6032e-04
Epoch 17/400
3/3 [==============================] - 0s 9ms/step - loss: 0.0014
Epoch 18/400
3/3 [==============================] - 0s 7ms/step - loss: 8.4534e-04
Epoch 19/400
3/3 [==============================] - 0s 7ms/step - loss: 5.9502e-04
Epoch 20/400
3/3 [==============================] - 0s 7ms/step - loss: 6.6146e-04
Epoch 21/400
3/3 [==============================] - 0s 7ms/step - loss: 3.2361e-04
Epoch 22/400
3/3 [==============================] - 0s 7ms/step - loss: 3.9021e-04
Epoch 23/400
3/3 [==============================] - 0s 8ms/step - loss: 2.5512e-04
Epoch 24/400
3/3 [==============================] - 0s 7ms/step - loss: 1.3374e-04
Epoch 25/400
3/3 [==============================] - 0s 8ms/step - loss: 1.4151e-04
Epoch 26/400
3/3 [==============================] - 0s 7ms/step - loss: 7.0648e-05
Epoch 27/400
3/3 [==============================] - 0s 7ms/step - loss: 9.5035e-05
Epoch 28/400
3/3 [==============================] - 0s 7ms/step - loss: 5.3864e-05
Epoch 29/400
3/3 [==============================] - 0s 9ms/step - loss: 5.5106e-05
Epoch 30/400
3/3 [==============================] - 0s 7ms/step - loss: 4.8803e-05
Epoch 31/400
3/3 [==============================] - 0s 7ms/step - loss: 4.1152e-05
Epoch 32/400
3/3 [==============================] - 0s 7ms/step - loss: 4.0835e-05
Epoch 33/400
3/3 [==============================] - 0s 7ms/step - loss: 3.1359e-05
Epoch 34/400
3/3 [==============================] - 0s 7ms/step - loss: 3.6417e-05
Epoch 35/400
3/3 [==============================] - 0s 7ms/step - loss: 2.7922e-05
Epoch 36/400
3/3 [==============================] - 0s 7ms/step - loss: 3.3740e-05
Epoch 37/400
3/3 [==============================] - 0s 7ms/step - loss: 2.7318e-05
Epoch 38/400
3/3 [==============================] - 0s 7ms/step - loss: 2.5229e-05
Epoch 39/400
3/3 [==============================] - 0s 7ms/step - loss: 2.4533e-05
Epoch 40/400
3/3 [==============================] - 0s 7ms/step - loss: 2.3937e-05
Epoch 41/400
3/3 [==============================] - 0s 7ms/step - loss: 2.3771e-05
Epoch 42/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2462e-05
Epoch 43/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1365e-05
Epoch 44/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1827e-05
Epoch 45/400
3/3 [==============================] - 0s 8ms/step - loss: 2.1915e-05
Epoch 46/400
3/3 [==============================] - 0s 7ms/step - loss: 2.0278e-05
Epoch 47/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1517e-05
Epoch 48/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1503e-05
Epoch 49/400
3/3 [==============================] - 0s 7ms/step - loss: 2.0990e-05
Epoch 50/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9814e-05
Epoch 51/400
3/3 [==============================] - 0s 7ms/step - loss: 1.8129e-05
Epoch 52/400
3/3 [==============================] - 0s 8ms/step - loss: 2.0218e-05
Epoch 53/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7866e-05
Epoch 54/400
3/3 [==============================] - 0s 9ms/step - loss: 2.0469e-05
Epoch 55/400
3/3 [==============================] - 0s 10ms/step - loss: 1.6357e-05
Epoch 56/400
3/3 [==============================] - 0s 11ms/step - loss: 1.6586e-05
Epoch 57/400
3/3 [==============================] - 0s 9ms/step - loss: 1.6716e-05
Epoch 58/400
3/3 [==============================] - 0s 10ms/step - loss: 1.7081e-05
Epoch 59/400
3/3 [==============================] - 0s 9ms/step - loss: 1.9227e-05
Epoch 60/400
3/3 [==============================] - 0s 9ms/step - loss: 2.3657e-05
Epoch 61/400
3/3 [==============================] - 0s 10ms/step - loss: 2.1468e-05
Epoch 62/400
3/3 [==============================] - 0s 11ms/step - loss: 1.5520e-05
Epoch 63/400
3/3 [==============================] - 0s 10ms/step - loss: 1.6634e-05
Epoch 64/400
3/3 [==============================] - 0s 10ms/step - loss: 1.5897e-05
Epoch 65/400
3/3 [==============================] - 0s 9ms/step - loss: 1.5901e-05
Epoch 66/400
3/3 [==============================] - 0s 9ms/step - loss: 1.4008e-05
Epoch 67/400
3/3 [==============================] - 0s 9ms/step - loss: 1.2894e-05
Epoch 68/400
3/3 [==============================] - 0s 10ms/step - loss: 1.2135e-05
Epoch 69/400
3/3 [==============================] - 0s 14ms/step - loss: 1.1874e-05
Epoch 70/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1589e-05
Epoch 71/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1927e-05
Epoch 72/400
3/3 [==============================] - 0s 9ms/step - loss: 1.2147e-05
Epoch 73/400
3/3 [==============================] - 0s 10ms/step - loss: 1.1717e-05
Epoch 74/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1388e-05
Epoch 75/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0980e-05
Epoch 76/400
3/3 [==============================] - 0s 9ms/step - loss: 1.2069e-05
Epoch 77/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0715e-05
Epoch 78/400
3/3 [==============================] - 0s 10ms/step - loss: 1.3065e-05
Epoch 79/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0699e-05
Epoch 80/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1122e-05
Epoch 81/400
3/3 [==============================] - 0s 9ms/step - loss: 1.7421e-05
Epoch 82/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1984e-05
Epoch 83/400
3/3 [==============================] - 0s 9ms/step - loss: 1.2846e-05
Epoch 84/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0822e-05
Epoch 85/400
3/3 [==============================] - 0s 9ms/step - loss: 9.3800e-06
Epoch 86/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0911e-05
Epoch 87/400
3/3 [==============================] - 0s 13ms/step - loss: 1.0150e-05
Epoch 88/400
3/3 [==============================] - 0s 10ms/step - loss: 9.9528e-06
Epoch 89/400
3/3 [==============================] - 0s 10ms/step - loss: 8.3236e-06
Epoch 90/400
3/3 [==============================] - 0s 10ms/step - loss: 8.1879e-06
Epoch 91/400
3/3 [==============================] - 0s 11ms/step - loss: 7.6161e-06
Epoch 92/400
3/3 [==============================] - 0s 11ms/step - loss: 7.5646e-06
Epoch 93/400
3/3 [==============================] - 0s 10ms/step - loss: 7.9415e-06
Epoch 94/400
3/3 [==============================] - 0s 10ms/step - loss: 7.1889e-06
Epoch 95/400
3/3 [==============================] - 0s 9ms/step - loss: 7.2984e-06
Epoch 96/400
3/3 [==============================] - 0s 9ms/step - loss: 7.2101e-06
Epoch 97/400
3/3 [==============================] - 0s 9ms/step - loss: 7.1218e-06
Epoch 98/400
3/3 [==============================] - 0s 9ms/step - loss: 6.4801e-06
Epoch 99/400
3/3 [==============================] - 0s 12ms/step - loss: 6.2027e-06
Epoch 100/400
3/3 [==============================] - 0s 13ms/step - loss: 5.9365e-06
Epoch 101/400
3/3 [==============================] - 0s 10ms/step - loss: 6.0997e-06
Epoch 102/400
3/3 [==============================] - 0s 10ms/step - loss: 5.7745e-06
Epoch 103/400
3/3 [==============================] - 0s 9ms/step - loss: 5.8552e-06
Epoch 104/400
3/3 [==============================] - 0s 9ms/step - loss: 5.5808e-06
Epoch 105/400
3/3 [==============================] - 0s 9ms/step - loss: 5.7799e-06
Epoch 106/400
3/3 [==============================] - 0s 9ms/step - loss: 5.6470e-06
Epoch 107/400
3/3 [==============================] - 0s 9ms/step - loss: 5.2613e-06
Epoch 108/400
3/3 [==============================] - 0s 9ms/step - loss: 5.1164e-06
Epoch 109/400
3/3 [==============================] - 0s 9ms/step - loss: 5.6274e-06
Epoch 110/400
3/3 [==============================] - 0s 9ms/step - loss: 5.6005e-06
Epoch 111/400
3/3 [==============================] - 0s 9ms/step - loss: 6.3889e-06
Epoch 112/400
3/3 [==============================] - 0s 9ms/step - loss: 5.4285e-06
Epoch 113/400
3/3 [==============================] - 0s 9ms/step - loss: 5.0031e-06
Epoch 114/400
3/3 [==============================] - 0s 10ms/step - loss: 5.1342e-06
Epoch 115/400
3/3 [==============================] - 0s 9ms/step - loss: 5.2845e-06
Epoch 116/400
3/3 [==============================] - 0s 8ms/step - loss: 4.8834e-06
Epoch 117/400
3/3 [==============================] - 0s 9ms/step - loss: 4.3960e-06
Epoch 118/400
3/3 [==============================] - 0s 9ms/step - loss: 4.2387e-06
Epoch 119/400
3/3 [==============================] - 0s 9ms/step - loss: 4.0498e-06
Epoch 120/400
3/3 [==============================] - 0s 12ms/step - loss: 4.1375e-06
Epoch 121/400
3/3 [==============================] - 0s 10ms/step - loss: 4.3151e-06
Epoch 122/400
3/3 [==============================] - 0s 11ms/step - loss: 4.2992e-06
Epoch 123/400
3/3 [==============================] - 0s 11ms/step - loss: 4.1030e-06
Epoch 124/400
3/3 [==============================] - 0s 10ms/step - loss: 4.2882e-06
Epoch 125/400
3/3 [==============================] - 0s 10ms/step - loss: 5.6323e-06
Epoch 126/400
3/3 [==============================] - 0s 9ms/step - loss: 3.8697e-06
Epoch 127/400
3/3 [==============================] - 0s 10ms/step - loss: 3.5723e-06
Epoch 128/400
3/3 [==============================] - 0s 11ms/step - loss: 3.4452e-06
Epoch 129/400
3/3 [==============================] - 0s 11ms/step - loss: 3.4537e-06
Epoch 130/400
3/3 [==============================] - 0s 10ms/step - loss: 3.8407e-06
Epoch 131/400
3/3 [==============================] - 0s 9ms/step - loss: 3.5546e-06
Epoch 132/400
3/3 [==============================] - 0s 9ms/step - loss: 3.8565e-06
Epoch 133/400
3/3 [==============================] - 0s 11ms/step - loss: 3.6444e-06
Epoch 134/400
3/3 [==============================] - 0s 10ms/step - loss: 3.4777e-06
Epoch 135/400
3/3 [==============================] - 0s 9ms/step - loss: 3.3452e-06
Epoch 136/400
3/3 [==============================] - 0s 9ms/step - loss: 3.9623e-06
Epoch 137/400
3/3 [==============================] - 0s 9ms/step - loss: 4.4268e-06
Epoch 138/400
3/3 [==============================] - 0s 11ms/step - loss: 4.0654e-06
Epoch 139/400
3/3 [==============================] - 0s 11ms/step - loss: 4.4941e-06
Epoch 140/400
3/3 [==============================] - 0s 9ms/step - loss: 3.1546e-06
Epoch 141/400
3/3 [==============================] - 0s 10ms/step - loss: 3.7683e-06
Epoch 142/400
3/3 [==============================] - 0s 11ms/step - loss: 3.0542e-06
Epoch 143/400
3/3 [==============================] - 0s 10ms/step - loss: 2.8238e-06
Epoch 144/400
3/3 [==============================] - 0s 10ms/step - loss: 3.3415e-06
Epoch 145/400
3/3 [==============================] - 0s 9ms/step - loss: 3.0545e-06
Epoch 146/400
3/3 [==============================] - 0s 10ms/step - loss: 3.3170e-06
Epoch 147/400
3/3 [==============================] - 0s 12ms/step - loss: 2.8700e-06
Epoch 148/400
3/3 [==============================] - 0s 12ms/step - loss: 2.7761e-06
Epoch 149/400
3/3 [==============================] - 0s 11ms/step - loss: 2.7103e-06
Epoch 150/400
3/3 [==============================] - 0s 12ms/step - loss: 2.6704e-06
Epoch 151/400
3/3 [==============================] - 0s 13ms/step - loss: 3.8398e-06
Epoch 152/400
3/3 [==============================] - 0s 8ms/step - loss: 4.1319e-06
Epoch 153/400
3/3 [==============================] - 0s 9ms/step - loss: 2.9868e-06
Epoch 154/400
3/3 [==============================] - 0s 9ms/step - loss: 3.6264e-06
Epoch 155/400
3/3 [==============================] - 0s 9ms/step - loss: 3.8313e-06
Epoch 156/400
3/3 [==============================] - 0s 11ms/step - loss: 4.0362e-06
Epoch 157/400
3/3 [==============================] - 0s 12ms/step - loss: 3.1535e-06
Epoch 158/400
3/3 [==============================] - 0s 11ms/step - loss: 2.8904e-06
Epoch 159/400
3/3 [==============================] - 0s 10ms/step - loss: 3.3380e-06
Epoch 160/400
3/3 [==============================] - 0s 9ms/step - loss: 3.5698e-06
Epoch 161/400
3/3 [==============================] - 0s 9ms/step - loss: 2.6752e-06
Epoch 162/400
3/3 [==============================] - 0s 9ms/step - loss: 2.3060e-06
Epoch 163/400
3/3 [==============================] - 0s 9ms/step - loss: 3.5703e-06
Epoch 164/400
3/3 [==============================] - 0s 9ms/step - loss: 3.3341e-06
Epoch 165/400
3/3 [==============================] - 0s 9ms/step - loss: 2.5389e-06
Epoch 166/400
3/3 [==============================] - 0s 9ms/step - loss: 2.7025e-06
Epoch 167/400
3/3 [==============================] - 0s 11ms/step - loss: 2.2809e-06
Epoch 168/400
3/3 [==============================] - 0s 10ms/step - loss: 2.0970e-06
Epoch 169/400
3/3 [==============================] - 0s 9ms/step - loss: 1.9233e-06
Epoch 170/400
3/3 [==============================] - 0s 9ms/step - loss: 1.8793e-06
Epoch 171/400
3/3 [==============================] - 0s 10ms/step - loss: 2.2439e-06
Epoch 172/400
3/3 [==============================] - 0s 10ms/step - loss: 2.5244e-06
Epoch 173/400
3/3 [==============================] - 0s 9ms/step - loss: 1.9137e-06
Epoch 174/400
3/3 [==============================] - 0s 11ms/step - loss: 2.9053e-06
Epoch 175/400
3/3 [==============================] - 0s 9ms/step - loss: 3.6664e-06
Epoch 176/400
3/3 [==============================] - 0s 10ms/step - loss: 3.0089e-06
Epoch 177/400
3/3 [==============================] - 0s 10ms/step - loss: 2.1626e-06
Epoch 178/400
3/3 [==============================] - 0s 11ms/step - loss: 2.7252e-06
Epoch 179/400
3/3 [==============================] - 0s 11ms/step - loss: 3.5647e-06
Epoch 180/400
3/3 [==============================] - 0s 11ms/step - loss: 2.0251e-06
Epoch 181/400
3/3 [==============================] - 0s 12ms/step - loss: 2.2876e-06
Epoch 182/400
3/3 [==============================] - 0s 11ms/step - loss: 2.1785e-06
Epoch 183/400
3/3 [==============================] - 0s 13ms/step - loss: 2.4774e-06
Epoch 184/400
3/3 [==============================] - 0s 12ms/step - loss: 3.3419e-06
Epoch 185/400
3/3 [==============================] - 0s 13ms/step - loss: 2.4871e-06
Epoch 186/400
3/3 [==============================] - 0s 11ms/step - loss: 2.2646e-06
Epoch 187/400
3/3 [==============================] - 0s 13ms/step - loss: 1.8824e-06
Epoch 188/400
3/3 [==============================] - 0s 12ms/step - loss: 1.7720e-06
Epoch 189/400
3/3 [==============================] - 0s 12ms/step - loss: 2.0210e-06
Epoch 190/400
3/3 [==============================] - 0s 13ms/step - loss: 2.1262e-06
Epoch 191/400
3/3 [==============================] - 0s 8ms/step - loss: 1.5924e-06
Epoch 192/400
3/3 [==============================] - 0s 8ms/step - loss: 2.0233e-06
Epoch 193/400
3/3 [==============================] - 0s 8ms/step - loss: 2.1536e-06
Epoch 194/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2172e-06
Epoch 195/400
3/3 [==============================] - 0s 8ms/step - loss: 2.4603e-06
Epoch 196/400
3/3 [==============================] - 0s 7ms/step - loss: 1.9421e-06
Epoch 197/400
3/3 [==============================] - 0s 8ms/step - loss: 3.2911e-06
Epoch 198/400
3/3 [==============================] - 0s 7ms/step - loss: 4.0038e-06
Epoch 199/400
3/3 [==============================] - 0s 7ms/step - loss: 2.3025e-06
Epoch 200/400
3/3 [==============================] - 0s 10ms/step - loss: 2.0633e-06
Epoch 201/400
3/3 [==============================] - 0s 9ms/step - loss: 2.6885e-06
Epoch 202/400
3/3 [==============================] - 0s 7ms/step - loss: 2.0328e-06
Epoch 203/400
3/3 [==============================] - 0s 7ms/step - loss: 1.4683e-06
Epoch 204/400
3/3 [==============================] - 0s 7ms/step - loss: 1.7798e-06
Epoch 205/400
3/3 [==============================] - 0s 10ms/step - loss: 2.2390e-06
Epoch 206/400
3/3 [==============================] - 0s 8ms/step - loss: 3.3311e-06
Epoch 207/400
3/3 [==============================] - 0s 8ms/step - loss: 2.6762e-06
Epoch 208/400
3/3 [==============================] - 0s 8ms/step - loss: 3.3784e-06
Epoch 209/400
3/3 [==============================] - 0s 7ms/step - loss: 4.5584e-06
Epoch 210/400
3/3 [==============================] - 0s 8ms/step - loss: 4.1900e-06
Epoch 211/400
3/3 [==============================] - 0s 7ms/step - loss: 3.0608e-06
Epoch 212/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2623e-06
Epoch 213/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1514e-06
Epoch 214/400
3/3 [==============================] - 0s 9ms/step - loss: 2.4836e-06
Epoch 215/400
3/3 [==============================] - 0s 7ms/step - loss: 2.8239e-06
Epoch 216/400
3/3 [==============================] - 0s 8ms/step - loss: 4.0723e-06
Epoch 217/400
3/3 [==============================] - 0s 8ms/step - loss: 3.4342e-06
Epoch 218/400
3/3 [==============================] - 0s 7ms/step - loss: 2.8737e-06
Epoch 219/400
3/3 [==============================] - 0s 7ms/step - loss: 2.9675e-06
Epoch 220/400
3/3 [==============================] - 0s 8ms/step - loss: 4.0445e-06
Epoch 221/400
3/3 [==============================] - 0s 8ms/step - loss: 2.0780e-06
Epoch 222/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9986e-06
Epoch 223/400
3/3 [==============================] - 0s 8ms/step - loss: 2.2424e-06
Epoch 224/400
3/3 [==============================] - 0s 7ms/step - loss: 1.6907e-06
Epoch 225/400
3/3 [==============================] - 0s 7ms/step - loss: 1.7528e-06
Epoch 226/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2419e-06
Epoch 227/400
3/3 [==============================] - 0s 9ms/step - loss: 2.1124e-06
Epoch 228/400
3/3 [==============================] - 0s 7ms/step - loss: 1.8432e-06
Epoch 229/400
3/3 [==============================] - 0s 7ms/step - loss: 1.6074e-06
Epoch 230/400
3/3 [==============================] - 0s 7ms/step - loss: 1.3449e-06
Epoch 231/400
3/3 [==============================] - 0s 7ms/step - loss: 1.2514e-06
Epoch 232/400
3/3 [==============================] - 0s 7ms/step - loss: 1.5562e-06
Epoch 233/400
3/3 [==============================] - 0s 8ms/step - loss: 1.5240e-06
Epoch 234/400
3/3 [==============================] - 0s 7ms/step - loss: 1.7097e-06
Epoch 235/400
3/3 [==============================] - 0s 7ms/step - loss: 2.5362e-06
Epoch 236/400
3/3 [==============================] - 0s 7ms/step - loss: 2.4041e-06
Epoch 237/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9567e-06
Epoch 238/400
3/3 [==============================] - 0s 7ms/step - loss: 1.3213e-06
Epoch 239/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2913e-06
Epoch 240/400
3/3 [==============================] - 0s 8ms/step - loss: 2.1645e-06
Epoch 241/400
3/3 [==============================] - 0s 8ms/step - loss: 1.4690e-06
Epoch 242/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1583e-06
Epoch 243/400
3/3 [==============================] - 0s 9ms/step - loss: 1.3944e-06
Epoch 244/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3120e-06
Epoch 245/400
3/3 [==============================] - 0s 8ms/step - loss: 1.5161e-06
Epoch 246/400
3/3 [==============================] - 0s 8ms/step - loss: 1.2940e-06
Epoch 247/400
3/3 [==============================] - 0s 8ms/step - loss: 1.2821e-06
Epoch 248/400
3/3 [==============================] - 0s 9ms/step - loss: 1.2954e-06
Epoch 249/400
3/3 [==============================] - 0s 8ms/step - loss: 1.1436e-06
Epoch 250/400
3/3 [==============================] - 0s 7ms/step - loss: 1.2465e-06
Epoch 251/400
3/3 [==============================] - 0s 7ms/step - loss: 1.3679e-06
Epoch 252/400
3/3 [==============================] - 0s 10ms/step - loss: 1.4495e-06
Epoch 253/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3301e-06
Epoch 254/400
3/3 [==============================] - 0s 8ms/step - loss: 1.5737e-06
Epoch 255/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3919e-06
Epoch 256/400
3/3 [==============================] - 0s 8ms/step - loss: 1.1467e-06
Epoch 257/400
3/3 [==============================] - 0s 7ms/step - loss: 1.3483e-06
Epoch 258/400
3/3 [==============================] - 0s 7ms/step - loss: 2.0196e-06
Epoch 259/400
3/3 [==============================] - 0s 7ms/step - loss: 2.6921e-06
Epoch 260/400
3/3 [==============================] - 0s 7ms/step - loss: 2.2052e-06
Epoch 261/400
3/3 [==============================] - 0s 8ms/step - loss: 1.4483e-06
Epoch 262/400
3/3 [==============================] - 0s 8ms/step - loss: 2.1281e-06
Epoch 263/400
3/3 [==============================] - 0s 8ms/step - loss: 3.3662e-06
Epoch 264/400
3/3 [==============================] - 0s 7ms/step - loss: 3.2618e-06
Epoch 265/400
3/3 [==============================] - 0s 8ms/step - loss: 2.5954e-06
Epoch 266/400
3/3 [==============================] - 0s 7ms/step - loss: 2.4945e-06
Epoch 267/400
3/3 [==============================] - 0s 7ms/step - loss: 3.3547e-06
Epoch 268/400
3/3 [==============================] - 0s 8ms/step - loss: 5.5381e-06
Epoch 269/400
3/3 [==============================] - 0s 8ms/step - loss: 6.5930e-06
Epoch 270/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7580e-06
Epoch 271/400
3/3 [==============================] - 0s 8ms/step - loss: 1.2027e-06
Epoch 272/400
3/3 [==============================] - 0s 11ms/step - loss: 1.2803e-06
Epoch 273/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7832e-06
Epoch 274/400
3/3 [==============================] - 0s 8ms/step - loss: 2.8064e-06
Epoch 275/400
3/3 [==============================] - 0s 7ms/step - loss: 7.0841e-06
Epoch 276/400
3/3 [==============================] - 0s 8ms/step - loss: 7.2662e-06
Epoch 277/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9148e-05
Epoch 278/400
3/3 [==============================] - 0s 9ms/step - loss: 1.1608e-05
Epoch 279/400
3/3 [==============================] - 0s 9ms/step - loss: 1.3601e-05
Epoch 280/400
3/3 [==============================] - 0s 8ms/step - loss: 8.5386e-06
Epoch 281/400
3/3 [==============================] - 0s 8ms/step - loss: 1.0328e-05
Epoch 282/400
3/3 [==============================] - 0s 8ms/step - loss: 1.1991e-05
Epoch 283/400
3/3 [==============================] - 0s 7ms/step - loss: 7.7127e-06
Epoch 284/400
3/3 [==============================] - 0s 7ms/step - loss: 7.0083e-06
Epoch 285/400
3/3 [==============================] - 0s 8ms/step - loss: 1.2078e-05
Epoch 286/400
3/3 [==============================] - 0s 8ms/step - loss: 6.2675e-06
Epoch 287/400
3/3 [==============================] - 0s 14ms/step - loss: 8.3599e-06
Epoch 288/400
3/3 [==============================] - 0s 11ms/step - loss: 5.8839e-06
Epoch 289/400
3/3 [==============================] - 0s 7ms/step - loss: 3.6037e-06
Epoch 290/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3230e-06
Epoch 291/400
3/3 [==============================] - 0s 8ms/step - loss: 1.4901e-06
Epoch 292/400
3/3 [==============================] - 0s 9ms/step - loss: 2.1717e-06
Epoch 293/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9586e-06
Epoch 294/400
3/3 [==============================] - 0s 8ms/step - loss: 1.5854e-06
Epoch 295/400
3/3 [==============================] - 0s 8ms/step - loss: 1.0590e-06
Epoch 296/400
3/3 [==============================] - 0s 8ms/step - loss: 1.0939e-06
Epoch 297/400
3/3 [==============================] - 0s 9ms/step - loss: 1.0990e-06
Epoch 298/400
3/3 [==============================] - 0s 12ms/step - loss: 1.1627e-06
Epoch 299/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3243e-06
Epoch 300/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3069e-06
Epoch 301/400
3/3 [==============================] - 0s 7ms/step - loss: 1.1750e-06
Epoch 302/400
3/3 [==============================] - 0s 8ms/step - loss: 1.2032e-06
Epoch 303/400
3/3 [==============================] - 0s 9ms/step - loss: 2.5275e-06
Epoch 304/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7112e-06
Epoch 305/400
3/3 [==============================] - 0s 7ms/step - loss: 2.8385e-06
Epoch 306/400
3/3 [==============================] - 0s 8ms/step - loss: 4.4028e-06
Epoch 307/400
3/3 [==============================] - 0s 9ms/step - loss: 5.0815e-06
Epoch 308/400
3/3 [==============================] - 0s 8ms/step - loss: 7.5952e-06
Epoch 309/400
3/3 [==============================] - 0s 8ms/step - loss: 1.1201e-05
Epoch 310/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7898e-05
Epoch 311/400
3/3 [==============================] - 0s 7ms/step - loss: 9.6612e-06
Epoch 312/400
3/3 [==============================] - 0s 7ms/step - loss: 1.1965e-05
Epoch 313/400
3/3 [==============================] - 0s 8ms/step - loss: 1.8997e-05
Epoch 314/400
3/3 [==============================] - 0s 8ms/step - loss: 2.2046e-05
Epoch 315/400
3/3 [==============================] - 0s 7ms/step - loss: 4.5703e-05
Epoch 316/400
3/3 [==============================] - 0s 7ms/step - loss: 3.1477e-05
Epoch 317/400
3/3 [==============================] - 0s 7ms/step - loss: 2.9032e-05
Epoch 318/400
3/3 [==============================] - 0s 7ms/step - loss: 1.7805e-05
Epoch 319/400
3/3 [==============================] - 0s 7ms/step - loss: 2.1616e-05
Epoch 320/400
3/3 [==============================] - 0s 9ms/step - loss: 1.8524e-05
Epoch 321/400
3/3 [==============================] - 0s 8ms/step - loss: 1.7145e-05
Epoch 322/400
3/3 [==============================] - 0s 8ms/step - loss: 1.3309e-05
Epoch 323/400
3/3 [==============================] - 0s 10ms/step - loss: 5.5201e-06
Epoch 324/400
3/3 [==============================] - 0s 9ms/step - loss: 6.8558e-06
Epoch 325/400
3/3 [==============================] - 0s 8ms/step - loss: 1.9082e-06
Epoch 326/400
3/3 [==============================] - 0s 12ms/step - loss: 2.2341e-06
Epoch 327/400
3/3 [==============================] - 0s 10ms/step - loss: 2.3292e-06
Epoch 328/400
3/3 [==============================] - 0s 10ms/step - loss: 3.0375e-06
Epoch 329/400
3/3 [==============================] - 0s 13ms/step - loss: 4.4716e-06
Epoch 330/400
3/3 [==============================] - 0s 16ms/step - loss: 2.0425e-06
Epoch 331/400
3/3 [==============================] - 0s 12ms/step - loss: 1.4447e-06
Epoch 332/400
3/3 [==============================] - 0s 10ms/step - loss: 1.3472e-06
Epoch 333/400
3/3 [==============================] - 0s 17ms/step - loss: 1.3515e-06
Epoch 334/400
3/3 [==============================] - 0s 14ms/step - loss: 1.3087e-06
Epoch 335/400
3/3 [==============================] - 0s 18ms/step - loss: 1.5281e-06
Epoch 336/400
3/3 [==============================] - 0s 13ms/step - loss: 1.5963e-06
Epoch 337/400
3/3 [==============================] - 0s 11ms/step - loss: 1.7587e-06
Epoch 338/400
3/3 [==============================] - 0s 15ms/step - loss: 2.5823e-06
Epoch 339/400
3/3 [==============================] - 0s 16ms/step - loss: 4.7698e-06
Epoch 340/400
3/3 [==============================] - 0s 11ms/step - loss: 9.1577e-06
Epoch 341/400
3/3 [==============================] - 0s 18ms/step - loss: 1.2486e-05
Epoch 342/400
3/3 [==============================] - 0s 13ms/step - loss: 1.1364e-05
Epoch 343/400
3/3 [==============================] - 0s 15ms/step - loss: 1.1751e-05
Epoch 344/400
3/3 [==============================] - 0s 11ms/step - loss: 4.3065e-06
Epoch 345/400
3/3 [==============================] - 0s 12ms/step - loss: 8.7047e-06
Epoch 346/400
3/3 [==============================] - 0s 10ms/step - loss: 6.0707e-06
Epoch 347/400
3/3 [==============================] - 0s 12ms/step - loss: 3.6290e-06
Epoch 348/400
3/3 [==============================] - 0s 13ms/step - loss: 3.3351e-06
Epoch 349/400
3/3 [==============================] - 0s 11ms/step - loss: 3.9788e-06
Epoch 350/400
3/3 [==============================] - 0s 11ms/step - loss: 7.2157e-06
Epoch 351/400
3/3 [==============================] - 0s 12ms/step - loss: 1.0251e-05
Epoch 352/400
3/3 [==============================] - 0s 12ms/step - loss: 3.6522e-06
Epoch 353/400
3/3 [==============================] - 0s 12ms/step - loss: 3.7692e-06
Epoch 354/400
3/3 [==============================] - 0s 11ms/step - loss: 2.2184e-06
Epoch 355/400
3/3 [==============================] - 0s 12ms/step - loss: 3.0729e-06
Epoch 356/400
3/3 [==============================] - 0s 16ms/step - loss: 2.3641e-06
Epoch 357/400
3/3 [==============================] - 0s 11ms/step - loss: 5.6655e-06
Epoch 358/400
3/3 [==============================] - 0s 11ms/step - loss: 6.9344e-06
Epoch 359/400
3/3 [==============================] - 0s 14ms/step - loss: 2.0580e-06
Epoch 360/400
3/3 [==============================] - 0s 16ms/step - loss: 9.2040e-06
Epoch 361/400
3/3 [==============================] - 0s 11ms/step - loss: 3.2863e-06
Epoch 362/400
3/3 [==============================] - 0s 12ms/step - loss: 2.6915e-06
Epoch 363/400
3/3 [==============================] - 0s 9ms/step - loss: 4.5898e-06
Epoch 364/400
3/3 [==============================] - 0s 17ms/step - loss: 8.6440e-06
Epoch 365/400
3/3 [==============================] - 0s 16ms/step - loss: 3.1356e-06
Epoch 366/400
3/3 [==============================] - 0s 10ms/step - loss: 2.5426e-06
Epoch 367/400
3/3 [==============================] - 0s 10ms/step - loss: 4.1343e-06
Epoch 368/400
3/3 [==============================] - 0s 20ms/step - loss: 2.7291e-06
Epoch 369/400
3/3 [==============================] - 0s 15ms/step - loss: 1.7993e-06
Epoch 370/400
3/3 [==============================] - 0s 18ms/step - loss: 3.6052e-06
Epoch 371/400
3/3 [==============================] - 0s 12ms/step - loss: 4.4178e-06
Epoch 372/400
3/3 [==============================] - 0s 17ms/step - loss: 8.7133e-06
Epoch 373/400
3/3 [==============================] - 0s 16ms/step - loss: 7.3080e-06
Epoch 374/400
3/3 [==============================] - 0s 14ms/step - loss: 2.0091e-06
Epoch 375/400
3/3 [==============================] - 0s 17ms/step - loss: 2.0008e-06
Epoch 376/400
3/3 [==============================] - 0s 15ms/step - loss: 2.9835e-06
Epoch 377/400
3/3 [==============================] - 0s 14ms/step - loss: 2.5821e-06
Epoch 378/400
3/3 [==============================] - 0s 22ms/step - loss: 5.1410e-06
Epoch 379/400
3/3 [==============================] - 0s 15ms/step - loss: 3.5277e-06
Epoch 380/400
3/3 [==============================] - 0s 13ms/step - loss: 3.2423e-06
Epoch 381/400
3/3 [==============================] - 0s 16ms/step - loss: 1.7107e-06
Epoch 382/400
3/3 [==============================] - 0s 19ms/step - loss: 2.4648e-06
Epoch 383/400
3/3 [==============================] - 0s 11ms/step - loss: 6.8383e-06
Epoch 384/400
3/3 [==============================] - 0s 15ms/step - loss: 1.5761e-05
Epoch 385/400
3/3 [==============================] - 0s 12ms/step - loss: 2.6183e-05
Epoch 386/400
3/3 [==============================] - 0s 12ms/step - loss: 1.0427e-04
Epoch 387/400
3/3 [==============================] - 0s 11ms/step - loss: 7.9516e-05
Epoch 388/400
3/3 [==============================] - 0s 12ms/step - loss: 2.4360e-05
Epoch 389/400
3/3 [==============================] - 0s 11ms/step - loss: 1.6230e-05
Epoch 390/400
3/3 [==============================] - 0s 18ms/step - loss: 1.3497e-05
Epoch 391/400
3/3 [==============================] - 0s 25ms/step - loss: 1.7710e-05
Epoch 392/400
3/3 [==============================] - 0s 25ms/step - loss: 1.7799e-05
Epoch 393/400
3/3 [==============================] - 0s 18ms/step - loss: 1.1646e-05
Epoch 394/400
3/3 [==============================] - 0s 15ms/step - loss: 1.5521e-05
Epoch 395/400
3/3 [==============================] - 0s 10ms/step - loss: 1.7312e-05
Epoch 396/400
3/3 [==============================] - 0s 10ms/step - loss: 1.1681e-05
Epoch 397/400
3/3 [==============================] - 0s 19ms/step - loss: 1.2667e-05
Epoch 398/400
3/3 [==============================] - 0s 22ms/step - loss: 2.1204e-05
Epoch 399/400
3/3 [==============================] - 0s 22ms/step - loss: 2.6879e-05
Epoch 400/400
3/3 [==============================] - 0s 20ms/step - loss: 2.3264e-05
In [ ]:
plt.plot(history.history['loss'], label='train loss')
# plt.plot(history.history['val_loss'], label='val loss')
plt.legend()
plt.show()
No description has been provided for this image

Rollout Prediction¶

In [ ]:
plt.figure(figsize=(12,5))
for i in range(15):
    scaler_test, test_inout_seq = make_inout_seq(5*i, 500)
    X_test = np.array([seq[0] for seq in test_inout_seq])
    y_test = np.array([seq[1] for seq in test_inout_seq])
    test_seq = X_test[0]
    for i in range(90):
        pred = model.predict(test_seq[i:][np.newaxis], verbose = 0)
        test_seq = np.concatenate([test_seq, pred], axis = 0).squeeze()

    pred_traj = scaler_test.inverse_transform(test_seq.reshape(-1,2))
    pred_traj = pred_traj[pred_traj[:,1]>=0]
    X_test_traj = scaler_test.inverse_transform(X_test[0].reshape(-1,2))
    y_test_traj = scaler_test.inverse_transform(y_test.reshape(-1,2))
    plt.plot(X_test_traj[:,0], X_test_traj[:,1])
    plt.plot(y_test_traj[:,0], y_test_traj[:,1], label = 'actual', color = 'blue')
    plt.plot(np.concatenate([X_test_traj[train_window-1,0][np.newaxis], pred_traj[:,0]], axis = 0),
             np.concatenate([X_test_traj[train_window-1,1][np.newaxis], pred_traj[:,1]], axis = 0), label = 'pred', color = 'red')
# plt.vlines(X_test_traj[:train_window,0][-1],0,np.max(y_test_traj[:,1])*1.1, color = 'red', linestyle='--')
handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
plt.legend(by_label.values(), by_label.keys(), fontsize = 15)
plt.title("Projectile Trajectory with Air Resistance", fontsize = 15)
plt.xlabel("Distance (m)", fontsize = 15)
plt.ylabel("Height (m)", fontsize = 15)
plt.grid(True)
plt.xlim([0,400])
plt.ylim([0,300])
Out[ ]:
(0.0, 300.0)