Find answers to common issues you may encounter when working with Dragonfly's Deep Learning Tool…

No. You can only create or use a model within the limitations listed below:

  • 2D models only.
  • Single input, single output.
  • Output shape must match the input shape.

This is the first version of our Deep Learning tool, and most model limitations will be addressed in future versions of the tool. We are currently working on supporting 3D models, multiple inputs and outputs, and other great features that will be included in the next Dragonfly release.

Absolutely. Keras models, saved as HDF5 files (with extension .h5 or .hdf5), can be imported into the Deep Trainer tool as long as they obey the constraints listed previously in these FAQs. Once imported into the tool, the model will have the same behaviour as the models created within the tool — you can apply, edit, and/or retrain them, if needed.

The classes number defines the output of the model and is dependent on the model type. Three model types are supported in Dragonfly:

  • Autoencoder and its variations - in this case the output of the model is some data encoded into a continuous range of values (i.e. a dataset), and the number of classes is defined as 1.
  • Binary segmentation - in this case we are looking for a single object in the image, and are trying to distinguish between it and all other objects in the image (or background). The number of classes is 2 in this case — one for the object and one for the background — and the target is generally represented by an ROI
  • Multi-label segmentation - similar to binary segmentation, but with more objects of interest. The target is generally represented by a multi-ROI.

No. The classes number is derived from the model and cannot be changed directly.

No. You can still use a model with a different number of classes, but you would need to edit it to reflect the new data or problem. We recommend that you preserve the original model by duplicating it.

Most commonly, the number of classes is derived from the "filters" attribute at the last convolutional layer, and you would need to edit its value. You might also need to edit the last activation function (could be defined as separate Activation layer, or as "activation" attribute, at one of the last layers, usually convolutional layer, - whatever comes last). It is recommended to use "sigmoid" activation for 1 class models, and "softmax for 2 or more classes.

Refer to https://keras.io/activations/ for more information about activation functions in Keras.

For easier visualization of the data flow through the model, you can use one of the two arrangement types:

  • Size: change in layer size represents respective change in data size.
  • Position: change in layer position represents a change in data size, shifting a layer downwards (in Horizontal layout), or right (in Vertical layout) represents decreasing data size, whereas shifting a layer in opposite direction (upwards, or left) represents increasing data size..

For convenience, both arrangement types can be used with either Horizontal or Vertical layouts, as shown below.

There might be a number of reasons for this.

  1. There are many different types of layers available in Keras, but not all of them are supported by Dragonfly, and thus such layers won't be available. Examples of such layers are Conv3D or MaxPooling1D.
  2. Some layers are re-defined in Keras with multiple names (aliases) and only one name will appear in the list. For example, although both Conv2D and Convolution2D can be used interchangeably in Python scripts, only one of them will appear in the list of layer types.
  3. The list of layer types can become somewhat lengthy, with most layer types are extremely rarely used or even completely irrelevant. For this reason we have defined a filter. By default, you are expected to find all mostly commonly used layer types in the list. However, if you wish to use other layers, which are not listed, try to change filter definition. Filter is defined by layer modules. I.e. checking/unchecking a module in Layer Types Filter will add/remove all the layer types (within constraints 1 and 2 above) defined in this module.

Training process is a heuristic search for an optimal solution. Unfortunately, sometimes it can get stuck in locally optimal solutions, whereas better globally optimal solutions exist. Changing training parameters (such as optimization algorithm) can be helpful sometimes. But oftentimes, such situations are caused by a bad starting point (for example when you start from a model pre-trained on a very different data and/or problem), and the only way to escape from such a local solution, is to start the training process over from a different start point. In Dragonfly, you can use Reset option, which randomizes learned weights. Depending on a complexity of your model, you might wish to Reset it a few times before starting a training process over (Tip: use Preview to evaluate your model).

Only valid Keras models can be saved. So If there is a problem with a model, save operation will fail. If the problem is obvious, for example when there are disconnected layers, Dragonfly will display a clear error message, which would explain the problem. However, in other cases, for example if there is a problem with layer attributes, Dragonfly will display an error message coming from Keras, which might or might not be clear to the user. Undoing recent changes and trying to save a model without those changes first might be a good strategy. You can also use Reload option to go back to the last saved model version.

To learn more about various layer attributes and how to properly use them, you can visit the Keras website and look for a particular layer type. In Arguments section for each layer type you will find a list of layer attributes, their meaning, and usage details.

There might be various reasons for this, such as wrong data type or wrong dimensions. If you point your mouse to the "+" button, you will see a tooltip that will help you to determine the problem.

Using more data to learn from is always beneficial, assuming the data is relevant to the problem. However, sometimes dataset include many irrelevant information which, if used for training, may cause optimization algorithm slow down or even go in a wrong direction. Reducing irrelevant information from the training data will generally lead to improvement in both training time and achieved results. An example of a dataset where using a mask could be highly beneficial, if not crucial, is shown at the image below.

  • During training, training data is split into small 2D data patches. The size of those patches is defined by the "Input (Patch) Size" parameter. Normally, the patch size is considerably smaller than the dimensions of the dataset.
  • The "Stride to Input Ratio" parameter controls the position of the next extracted data patch. With a value of 1 there is no overlap between patches and they are extracted sequentially one after another. A value of 0 will lead to extracting patches at each voxel. At a value of 0.5 there will be a 50% overlap. Any value greater than 1 will lead to gaps between data patches.
  • Patches are randomly processed in batches and the "Batch Size" parameter determines the number of patches in a batch.
  • A single pass over all the data patches is called epoch, and the number of epochs is controlled by the "Epochs Number" parameter.
  • The "Loss Function" is used to compute the distance between a model outcome and the desired solution (target). This function is optimized during the training. You should note that not all the loss functions will work well with all the models and the default value is set according to the model type. Go to https://keras.io/losses/ to learn more about loss functions.
  • The "Optimization Algorithm" is a heuristic algorithm used for searching for an optimal solution. You can find more information about optimization algorithms in Keras at: https://keras.io/optimizers/.

Training is a heuristic process, and choosing a good set of training parameters can be quite challenging. Sometimes you have hardware limitations too. We try to help users by providing an initial set of training parameters, which would work well in most cases. Training parameters are saved with the model, and can be reused for future training.

Some models define an input size as part of the model. These are called fixed-size models. Trying to use these models with different sizes of input data will cause an error. Other models do not specify input size, but rather define a placeholder for the input. These variable-size models can be used with various input sizes, provided that a valid output can be computed for each model layer.

Callbacks are functions called at the particular time points during the training process, usually at the end of a training epoch or at the end of batch processing. In the current version, three callbacks are supported:

  • Early Stopping - Stops training upon a particular condition (generally, if the results do not improve).
  • Model Checkpoint - Saves the model during the training.
  • Terminate On NaN - Stops training if it gets into an illegal state.

For more information about callbacks, refer to: https://keras.io/callbacks/.

Although callbacks are great when you know how to use them, they might cause undesired consequences when used improperly. For example, "Early Stopping" might stop a training process too early, while a better solution could be found if the training process would continue. This is why callbacks appear in "Advanced Settings" section of training parameters and are turned off by default.

Training a good deep model with a small amount of data is quite challenging. One way to overcome this, is to use pre-trained model and fine tune it to your data. If your data and/or problem is very different, and none of the pre-trained models work well for you, you might wish to build and train your own model. In this case, we recommend to use more shallow architectures, as adding more layers to the model would increase a risk of overfitting.

Every machine learning algorithm, whether deep or not, is prone to overfitting. Overfitting is a situation in which an algorithm just memorizes the data from training and fails to provide good results on new, previously unseen data. In order to avoid this situation, a separate data should be used for algorithm validation. This data has to be different from the data used in training.

In Dragonfly, you can either randomly split the available data into training and validation, specifying a percentage of the data to be preserved for validation, or to provide separate validation data explicitly. If you have only one dataset, you can reuse it for both training and validation by defining non-intersecting masks.

Although we don't force using validation, we strongly recommend it, even if the amount of data is limited. The reason is that the training error will always decrease during the training, and monitoring its value is useless. However, if we have validation data and monitor validation error, we can detect a point when the validation error starts increasing. This means that the algorithm starts overfitting, and training process should be stopped.

Image source: https://visualstudiomagazine.com/articles/2015/05/01/train-validate-test-stopping.aspx

Has Dragonfly Convinced You?

Start enjoying all Dragonfly included features with a free 30-day trial version.