Demo: Neural network training for isotropic reconstruction of Zebrafish retina

This notebook demonstrates training a CARE model for an isotropic reconstruction task, assuming that training data was already generated via 1_datagen.ipynb and has been saved to disk to the file data/my_training_data.npz. Note that the training approach is exactly the same as in the standard CARE approach, what differs is the training data generation and prediction.

Note that training a neural network for actual use should be done on more (representative) data and with more training time.

More documentation is available at http://csbdeep.bioimagecomputing.com/doc/.

In [1]:
from __future__ import print_function, unicode_literals, absolute_import, division
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

from tifffile import imread
from csbdeep.utils import axes_dict, plot_some, plot_history
from csbdeep.utils.tf import limit_gpu_memory
from csbdeep.io import load_training_data
from csbdeep.models import Config, IsotropicCARE
Using TensorFlow backend.

The TensorFlow backend uses all available GPU memory by default, hence it can be useful to limit it:

In [2]:
# limit_gpu_memory(fraction=1/2)

Training data

Load training data generated via 1_datagen.ipynb, use 10% as validation data.

In [3]:
(X,Y), (X_val,Y_val), axes = load_training_data('data/my_training_data.npz', validation_split=0.1, verbose=True)

c = axes_dict(axes)['C']
n_channel_in, n_channel_out = X.shape[c], Y.shape[c]
number of training images:	 461
number of validation images:	 51
image size (2D):		 (128, 128)
axes:				 SYXC
channels in / out:		 2 / 2
In [4]:
plt.figure(figsize=(12,5))
plot_some(X_val[:5],Y_val[:5])
plt.suptitle('5 example validation patches (top row: source, bottom row: target)');

CARE model

Before we construct the actual CARE model, we have to define its configuration via a Config object, which includes

  • parameters of the underlying neural network,
  • the learning rate,
  • the number of parameter updates per epoch,
  • the loss function, and
  • whether the model is probabilistic or not.

The defaults should be sensible in many cases, so a change should only be necessary if the training process fails.


Important: Note that for this notebook we use a very small number of update steps per epoch for immediate feedback, whereas this number should be increased considerably (e.g. train_steps_per_epoch=400) to obtain a well-trained model.

In [5]:
config = Config(axes, n_channel_in, n_channel_out, train_steps_per_epoch=30)
print(config)
vars(config)
Config(axes='YXC', n_channel_in=2, n_channel_out=2, n_dim=2, probabilistic=False, train_batch_size=16, train_checkpoint='weights_best.h5', train_checkpoint_epoch='weights_now.h5', train_checkpoint_last='weights_last.h5', train_epochs=100, train_learning_rate=0.0004, train_loss='mae', train_reduce_lr={'factor': 0.5, 'patience': 10, 'min_delta': 0}, train_steps_per_epoch=30, train_tensorboard=True, unet_input_shape=(None, None, 2), unet_kern_size=5, unet_last_activation='linear', unet_n_depth=2, unet_n_first=32, unet_residual=True)
Out[5]:
{'axes': 'YXC',
 'n_channel_in': 2,
 'n_channel_out': 2,
 'n_dim': 2,
 'probabilistic': False,
 'train_batch_size': 16,
 'train_checkpoint': 'weights_best.h5',
 'train_checkpoint_epoch': 'weights_now.h5',
 'train_checkpoint_last': 'weights_last.h5',
 'train_epochs': 100,
 'train_learning_rate': 0.0004,
 'train_loss': 'mae',
 'train_reduce_lr': {'factor': 0.5, 'min_delta': 0, 'patience': 10},
 'train_steps_per_epoch': 30,
 'train_tensorboard': True,
 'unet_input_shape': (None, None, 2),
 'unet_kern_size': 5,
 'unet_last_activation': 'linear',
 'unet_n_depth': 2,
 'unet_n_first': 32,
 'unet_residual': True}

We now create an isotropic CARE model with the chosen configuration:

In [6]:
model = IsotropicCARE(config, 'my_model', basedir='models')

Training

Training the model will likely take some time. We recommend to monitor the progress with TensorBoard (example below), which allows you to inspect the losses during training. Furthermore, you can look at the predictions for some of the validation images, which can be helpful to recognize problems early on.

You can start TensorBoard from the current working directory with tensorboard --logdir=. Then connect to http://localhost:6006/ with your browser.

In [7]:
history = model.train(X,Y, validation_data=(X_val,Y_val))
Epoch 1/100
30/30 [==============================] - 6s 199ms/step - loss: 0.0391 - mse: 0.0038 - mae: 0.0391 - val_loss: 0.0409 - val_mse: 0.0043 - val_mae: 0.0409
Epoch 2/100
30/30 [==============================] - 3s 97ms/step - loss: 0.0379 - mse: 0.0036 - mae: 0.0379 - val_loss: 0.0404 - val_mse: 0.0042 - val_mae: 0.0404
Epoch 3/100
30/30 [==============================] - 3s 98ms/step - loss: 0.0370 - mse: 0.0035 - mae: 0.0370 - val_loss: 0.0390 - val_mse: 0.0039 - val_mae: 0.0390
Epoch 4/100
30/30 [==============================] - 3s 97ms/step - loss: 0.0356 - mse: 0.0032 - mae: 0.0356 - val_loss: 0.0376 - val_mse: 0.0036 - val_mae: 0.0376
Epoch 5/100
30/30 [==============================] - 3s 99ms/step - loss: 0.0341 - mse: 0.0028 - mae: 0.0341 - val_loss: 0.0361 - val_mse: 0.0033 - val_mae: 0.0361
Epoch 6/100
30/30 [==============================] - 3s 100ms/step - loss: 0.0333 - mse: 0.0026 - mae: 0.0333 - val_loss: 0.0347 - val_mse: 0.0029 - val_mae: 0.0347
Epoch 7/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0331 - mse: 0.0026 - mae: 0.0331 - val_loss: 0.0341 - val_mse: 0.0028 - val_mae: 0.0341
Epoch 8/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0315 - mse: 0.0022 - mae: 0.0315 - val_loss: 0.0335 - val_mse: 0.0026 - val_mae: 0.0335
Epoch 9/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0310 - mse: 0.0021 - mae: 0.0310 - val_loss: 0.0328 - val_mse: 0.0025 - val_mae: 0.0328
Epoch 10/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0310 - mse: 0.0021 - mae: 0.0310 - val_loss: 0.0326 - val_mse: 0.0024 - val_mae: 0.0326
Epoch 11/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0306 - mse: 0.0021 - mae: 0.0306 - val_loss: 0.0321 - val_mse: 0.0023 - val_mae: 0.0321
Epoch 12/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0304 - mse: 0.0020 - mae: 0.0304 - val_loss: 0.0322 - val_mse: 0.0023 - val_mae: 0.0322
Epoch 13/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0305 - mse: 0.0020 - mae: 0.0305 - val_loss: 0.0322 - val_mse: 0.0023 - val_mae: 0.0322
Epoch 14/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0298 - mse: 0.0019 - mae: 0.0298 - val_loss: 0.0315 - val_mse: 0.0022 - val_mae: 0.0315
Epoch 15/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0296 - mse: 0.0018 - mae: 0.0296 - val_loss: 0.0318 - val_mse: 0.0022 - val_mae: 0.0318
Epoch 16/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0296 - mse: 0.0018 - mae: 0.0296 - val_loss: 0.0315 - val_mse: 0.0022 - val_mae: 0.0315
Epoch 17/100
30/30 [==============================] - 3s 109ms/step - loss: 0.0293 - mse: 0.0018 - mae: 0.0293 - val_loss: 0.0311 - val_mse: 0.0021 - val_mae: 0.0311
Epoch 18/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0291 - mse: 0.0018 - mae: 0.0291 - val_loss: 0.0310 - val_mse: 0.0021 - val_mae: 0.0310
Epoch 19/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0289 - mse: 0.0017 - mae: 0.0289 - val_loss: 0.0310 - val_mse: 0.0021 - val_mae: 0.0310
Epoch 20/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0291 - mse: 0.0017 - mae: 0.0291 - val_loss: 0.0310 - val_mse: 0.0021 - val_mae: 0.0310
Epoch 21/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0284 - mse: 0.0016 - mae: 0.0284 - val_loss: 0.0308 - val_mse: 0.0020 - val_mae: 0.0308
Epoch 22/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0288 - mse: 0.0017 - mae: 0.0288 - val_loss: 0.0311 - val_mse: 0.0021 - val_mae: 0.0311
Epoch 23/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0284 - mse: 0.0016 - mae: 0.0284 - val_loss: 0.0308 - val_mse: 0.0020 - val_mae: 0.0308
Epoch 24/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0283 - mse: 0.0016 - mae: 0.0283 - val_loss: 0.0306 - val_mse: 0.0020 - val_mae: 0.0306
Epoch 25/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0282 - mse: 0.0016 - mae: 0.0282 - val_loss: 0.0306 - val_mse: 0.0020 - val_mae: 0.0306
Epoch 26/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0283 - mse: 0.0016 - mae: 0.0283 - val_loss: 0.0305 - val_mse: 0.0020 - val_mae: 0.0305
Epoch 27/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0280 - mse: 0.0015 - mae: 0.0280 - val_loss: 0.0304 - val_mse: 0.0020 - val_mae: 0.0304
Epoch 28/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0279 - mse: 0.0015 - mae: 0.0279 - val_loss: 0.0304 - val_mse: 0.0020 - val_mae: 0.0304
Epoch 29/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0278 - mse: 0.0015 - mae: 0.0278 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 30/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0277 - mse: 0.0015 - mae: 0.0277 - val_loss: 0.0306 - val_mse: 0.0020 - val_mae: 0.0306
Epoch 31/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0275 - mse: 0.0015 - mae: 0.0275 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 32/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0277 - mse: 0.0015 - mae: 0.0277 - val_loss: 0.0306 - val_mse: 0.0020 - val_mae: 0.0306
Epoch 33/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0273 - mse: 0.0014 - mae: 0.0273 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 34/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0274 - mse: 0.0014 - mae: 0.0274 - val_loss: 0.0304 - val_mse: 0.0020 - val_mae: 0.0304
Epoch 35/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0272 - mse: 0.0014 - mae: 0.0272 - val_loss: 0.0303 - val_mse: 0.0019 - val_mae: 0.0303
Epoch 36/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0271 - mse: 0.0014 - mae: 0.0271 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 37/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0273 - mse: 0.0014 - mae: 0.0273 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 38/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0269 - mse: 0.0014 - mae: 0.0269 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 39/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0272 - mse: 0.0014 - mae: 0.0272 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 40/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0266 - mse: 0.0013 - mae: 0.0266 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 41/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0266 - mse: 0.0013 - mae: 0.0266 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 42/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0269 - mse: 0.0014 - mae: 0.0269 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 43/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0267 - mse: 0.0014 - mae: 0.0267 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 44/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0268 - mse: 0.0014 - mae: 0.0268 - val_loss: 0.0306 - val_mse: 0.0020 - val_mae: 0.0306
Epoch 45/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0267 - mse: 0.0013 - mae: 0.0267 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 46/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0266 - mse: 0.0013 - mae: 0.0266 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 47/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0263 - mse: 0.0013 - mae: 0.0263 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 48/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0265 - mse: 0.0013 - mae: 0.0265 - val_loss: 0.0302 - val_mse: 0.0019 - val_mae: 0.0302
Epoch 49/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0263 - mse: 0.0013 - mae: 0.0263 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 50/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0262 - mse: 0.0013 - mae: 0.0262 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 51/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 52/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0262 - mse: 0.0013 - mae: 0.0262 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 53/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 54/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0304 - val_mse: 0.0020 - val_mae: 0.0304
Epoch 55/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0264 - mse: 0.0013 - mae: 0.0264 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 56/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 57/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 58/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0261 - mse: 0.0013 - mae: 0.0261 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 59/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 60/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0257 - mse: 0.0012 - mae: 0.0257 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 61/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0256 - mse: 0.0012 - mae: 0.0256 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 62/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0257 - mse: 0.0012 - mae: 0.0257 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 63/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0255 - mse: 0.0012 - mae: 0.0255 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 64/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0257 - mse: 0.0012 - mae: 0.0257 - val_loss: 0.0303 - val_mse: 0.0020 - val_mae: 0.0303
Epoch 65/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0257 - mse: 0.0012 - mae: 0.0257 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 66/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0255 - mse: 0.0012 - mae: 0.0255 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 67/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0256 - mse: 0.0012 - mae: 0.0256 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 68/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0255 - mse: 0.0012 - mae: 0.0255 - val_loss: 0.0299 - val_mse: 0.0019 - val_mae: 0.0299
Epoch 69/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0253 - mse: 0.0012 - mae: 0.0253 - val_loss: 0.0299 - val_mse: 0.0019 - val_mae: 0.0299
Epoch 70/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0251 - mse: 0.0011 - mae: 0.0251 - val_loss: 0.0301 - val_mse: 0.0019 - val_mae: 0.0301
Epoch 71/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0254 - mse: 0.0012 - mae: 0.0254 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 72/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0253 - mse: 0.0012 - mae: 0.0253 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 73/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0253 - mse: 0.0012 - mae: 0.0253 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 74/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0252 - mse: 0.0012 - mae: 0.0252 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 75/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0250 - mse: 0.0011 - mae: 0.0250 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 76/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0252 - mse: 0.0012 - mae: 0.0252 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 77/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0251 - mse: 0.0011 - mae: 0.0251 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 78/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0251 - mse: 0.0011 - mae: 0.0251 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301

Epoch 00078: ReduceLROnPlateau reducing learning rate to 0.00019999999494757503.
Epoch 79/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0249 - mse: 0.0011 - mae: 0.0249 - val_loss: 0.0299 - val_mse: 0.0019 - val_mae: 0.0299
Epoch 80/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0248 - mse: 0.0011 - mae: 0.0248 - val_loss: 0.0299 - val_mse: 0.0019 - val_mae: 0.0299
Epoch 81/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0300 - val_mse: 0.0020 - val_mae: 0.0300
Epoch 82/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0299 - val_mse: 0.0019 - val_mae: 0.0299
Epoch 83/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0247 - mse: 0.0011 - mae: 0.0247 - val_loss: 0.0300 - val_mse: 0.0019 - val_mae: 0.0300
Epoch 84/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0300 - val_mse: 0.0020 - val_mae: 0.0300
Epoch 85/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0300 - val_mse: 0.0020 - val_mae: 0.0300
Epoch 86/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0300 - val_mse: 0.0020 - val_mae: 0.0300
Epoch 87/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 88/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 89/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302

Epoch 00089: ReduceLROnPlateau reducing learning rate to 9.999999747378752e-05.
Epoch 90/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 91/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 92/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0243 - mse: 0.0011 - mae: 0.0243 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 93/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 94/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 95/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 96/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 97/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 98/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0243 - mse: 0.0011 - mae: 0.0243 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 99/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301

Epoch 00099: ReduceLROnPlateau reducing learning rate to 4.999999873689376e-05.
Epoch 100/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0242 - mse: 0.0011 - mae: 0.0242 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301

Loading network weights from 'weights_best.h5'.

Plot final training history (available in TensorBoard during training):

In [8]:
print(sorted(list(history.history.keys())))
plt.figure(figsize=(16,5))
plot_history(history,['loss','val_loss'],['mse','val_mse','mae','val_mae']);
['loss', 'lr', 'mae', 'mse', 'val_loss', 'val_mae', 'val_mse']

Evaluation

Example results for validation images.

In [9]:
plt.figure(figsize=(12,7))
_P = model.keras_model.predict(X_val[:5])
if config.probabilistic:
    _P = _P[...,:(_P.shape[-1]//2)]
plot_some(X_val[:5],Y_val[:5],_P,pmax=99.5)
plt.suptitle('5 example validation patches\n'      
             'top row: input (source),  '          
             'middle row: target (ground truth),  '
             'bottom row: predicted from source');