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_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_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 192ms/step - loss: 0.0383 - mse: 0.0036 - mae: 0.0383 - val_loss: 0.0387 - val_mse: 0.0040 - val_mae: 0.0387
Epoch 2/100
30/30 [==============================] - 3s 96ms/step - loss: 0.0376 - mse: 0.0036 - mae: 0.0376 - val_loss: 0.0379 - val_mse: 0.0038 - val_mae: 0.0379
Epoch 3/100
30/30 [==============================] - 3s 96ms/step - loss: 0.0362 - mse: 0.0033 - mae: 0.0362 - val_loss: 0.0368 - val_mse: 0.0036 - val_mae: 0.0368
Epoch 4/100
30/30 [==============================] - 3s 97ms/step - loss: 0.0354 - mse: 0.0031 - mae: 0.0354 - val_loss: 0.0355 - val_mse: 0.0033 - val_mae: 0.0355
Epoch 5/100
30/30 [==============================] - 3s 97ms/step - loss: 0.0339 - mse: 0.0028 - mae: 0.0339 - val_loss: 0.0344 - val_mse: 0.0030 - val_mae: 0.0344
Epoch 6/100
30/30 [==============================] - 3s 98ms/step - loss: 0.0334 - mse: 0.0026 - mae: 0.0334 - val_loss: 0.0337 - val_mse: 0.0028 - val_mae: 0.0337
Epoch 7/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0323 - mse: 0.0024 - mae: 0.0323 - val_loss: 0.0328 - val_mse: 0.0026 - val_mae: 0.0328
Epoch 8/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0313 - mse: 0.0022 - mae: 0.0313 - val_loss: 0.0320 - val_mse: 0.0024 - val_mae: 0.0320
Epoch 9/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0308 - mse: 0.0021 - mae: 0.0308 - val_loss: 0.0315 - val_mse: 0.0023 - val_mae: 0.0315
Epoch 10/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0305 - mse: 0.0020 - mae: 0.0305 - val_loss: 0.0313 - val_mse: 0.0022 - val_mae: 0.0313
Epoch 11/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0302 - mse: 0.0020 - mae: 0.0302 - val_loss: 0.0310 - val_mse: 0.0022 - val_mae: 0.0310
Epoch 12/100
30/30 [==============================] - 3s 109ms/step - loss: 0.0302 - mse: 0.0020 - mae: 0.0302 - val_loss: 0.0308 - val_mse: 0.0021 - val_mae: 0.0308
Epoch 13/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0294 - mse: 0.0018 - mae: 0.0294 - val_loss: 0.0306 - val_mse: 0.0021 - val_mae: 0.0306
Epoch 14/100
30/30 [==============================] - 3s 109ms/step - loss: 0.0292 - mse: 0.0018 - mae: 0.0292 - val_loss: 0.0305 - val_mse: 0.0021 - val_mae: 0.0305
Epoch 15/100
30/30 [==============================] - 3s 110ms/step - loss: 0.0293 - mse: 0.0018 - mae: 0.0293 - val_loss: 0.0304 - val_mse: 0.0020 - val_mae: 0.0304
Epoch 16/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0292 - mse: 0.0018 - mae: 0.0292 - val_loss: 0.0304 - val_mse: 0.0021 - val_mae: 0.0304
Epoch 17/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0286 - mse: 0.0017 - mae: 0.0286 - val_loss: 0.0302 - val_mse: 0.0020 - val_mae: 0.0302
Epoch 18/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0290 - mse: 0.0017 - mae: 0.0290 - val_loss: 0.0304 - val_mse: 0.0021 - val_mae: 0.0304
Epoch 19/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0284 - mse: 0.0016 - mae: 0.0284 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 20/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0282 - mse: 0.0016 - mae: 0.0282 - val_loss: 0.0301 - val_mse: 0.0020 - val_mae: 0.0301
Epoch 21/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0282 - mse: 0.0016 - mae: 0.0282 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 22/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0281 - mse: 0.0016 - mae: 0.0281 - val_loss: 0.0300 - val_mse: 0.0020 - val_mae: 0.0300
Epoch 23/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0278 - mse: 0.0015 - mae: 0.0278 - val_loss: 0.0299 - val_mse: 0.0020 - val_mae: 0.0299
Epoch 24/100
30/30 [==============================] - 3s 108ms/step - loss: 0.0279 - mse: 0.0016 - mae: 0.0279 - val_loss: 0.0299 - val_mse: 0.0020 - val_mae: 0.0299
Epoch 25/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0278 - mse: 0.0015 - mae: 0.0278 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 26/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0273 - mse: 0.0015 - mae: 0.0273 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 27/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0274 - mse: 0.0015 - mae: 0.0274 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 28/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0273 - mse: 0.0015 - mae: 0.0273 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 29/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0274 - mse: 0.0015 - mae: 0.0274 - val_loss: 0.0299 - val_mse: 0.0020 - val_mae: 0.0299
Epoch 30/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0270 - mse: 0.0014 - mae: 0.0270 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 31/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0270 - mse: 0.0014 - mae: 0.0270 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 32/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0267 - mse: 0.0014 - mae: 0.0267 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 33/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0268 - mse: 0.0014 - mae: 0.0268 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 34/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0268 - mse: 0.0014 - mae: 0.0268 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 35/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0264 - mse: 0.0013 - mae: 0.0264 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 36/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0266 - mse: 0.0014 - mae: 0.0266 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 37/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0265 - mse: 0.0013 - mae: 0.0265 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 38/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0264 - mse: 0.0013 - mae: 0.0264 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 39/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0263 - mse: 0.0013 - mae: 0.0263 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 40/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0263 - mse: 0.0013 - mae: 0.0263 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 41/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0261 - mse: 0.0013 - mae: 0.0261 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 42/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0261 - mse: 0.0013 - mae: 0.0261 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 43/100
30/30 [==============================] - 3s 116ms/step - loss: 0.0265 - mse: 0.0013 - mae: 0.0265 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 44/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0259 - mse: 0.0013 - mae: 0.0259 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 45/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 46/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 47/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0260 - mse: 0.0013 - mae: 0.0260 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 48/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0256 - mse: 0.0012 - mae: 0.0256 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 49/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0297 - val_mse: 0.0019 - val_mae: 0.0297
Epoch 50/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0298 - val_mse: 0.0020 - val_mae: 0.0298
Epoch 51/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0258 - mse: 0.0012 - mae: 0.0258 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 52/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0255 - mse: 0.0012 - mae: 0.0255 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 53/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0259 - mse: 0.0012 - mae: 0.0259 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 54/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0255 - mse: 0.0012 - mae: 0.0255 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 55/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0254 - mse: 0.0012 - mae: 0.0254 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 56/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0253 - mse: 0.0012 - mae: 0.0253 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 57/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0254 - mse: 0.0012 - mae: 0.0254 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 58/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0253 - mse: 0.0012 - mae: 0.0253 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 59/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0252 - mse: 0.0012 - mae: 0.0252 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 60/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0252 - mse: 0.0012 - mae: 0.0252 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 61/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0252 - mse: 0.0012 - mae: 0.0252 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 62/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0250 - mse: 0.0011 - mae: 0.0250 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 63/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0251 - mse: 0.0012 - mae: 0.0251 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295

Epoch 00063: ReduceLROnPlateau reducing learning rate to 0.00019999999494757503.
Epoch 64/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0249 - mse: 0.0011 - mae: 0.0249 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 65/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0247 - mse: 0.0011 - mae: 0.0247 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 66/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0247 - mse: 0.0011 - mae: 0.0247 - val_loss: 0.0294 - val_mse: 0.0019 - val_mae: 0.0294
Epoch 67/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 68/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0247 - mse: 0.0011 - mae: 0.0247 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 69/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 70/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 71/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0245 - mse: 0.0011 - mae: 0.0245 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 72/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 73/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0246 - mse: 0.0011 - mae: 0.0246 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 74/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296

Epoch 00074: ReduceLROnPlateau reducing learning rate to 9.999999747378752e-05.
Epoch 75/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0295 - val_mse: 0.0019 - val_mae: 0.0295
Epoch 76/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0243 - mse: 0.0010 - mae: 0.0243 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 77/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 78/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 79/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0242 - mse: 0.0011 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0019 - val_mae: 0.0296
Epoch 80/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0244 - mse: 0.0011 - mae: 0.0244 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 81/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 82/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 83/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 84/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0243 - mse: 0.0011 - mae: 0.0243 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296

Epoch 00084: ReduceLROnPlateau reducing learning rate to 4.999999873689376e-05.
Epoch 85/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 86/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 87/100
30/30 [==============================] - 3s 107ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 88/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 89/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0242 - mse: 0.0011 - mae: 0.0242 - val_loss: 0.0296 - val_mse: 0.0020 - val_mae: 0.0296
Epoch 90/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 91/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0240 - mse: 0.0010 - mae: 0.0240 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 92/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 93/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0240 - mse: 0.0010 - mae: 0.0240 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 94/100
30/30 [==============================] - 3s 105ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297

Epoch 00094: ReduceLROnPlateau reducing learning rate to 2.499999936844688e-05.
Epoch 95/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 96/100
30/30 [==============================] - 3s 103ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 97/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0241 - mse: 0.0010 - mae: 0.0241 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 98/100
30/30 [==============================] - 3s 106ms/step - loss: 0.0239 - mse: 0.0010 - mae: 0.0239 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 99/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0240 - mse: 0.0010 - mae: 0.0240 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297
Epoch 100/100
30/30 [==============================] - 3s 104ms/step - loss: 0.0242 - mse: 0.0010 - mae: 0.0242 - val_loss: 0.0297 - val_mse: 0.0020 - val_mae: 0.0297

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');