Toml files

Much of the input in OrcaNet is given as toml files. This page shows examples for the proper format, as well as possible options.

toml files for the Organizer

The orcanet.core.Organizer takes a list_file and a config_file argument, which are the pathes to the respective files.

Here are examples for the proper file formats:

list_file

examples/list.toml
 1# Defines the input files of the network. In this example, we want to read
 2# from two different sets of files at the same time.
 3
 4
 5# Name of this input set. If this is the name of an input layer of the
 6# model, it will get data from this set. Otherwise, you have to use a
 7# sample modifier.
 8[input_A]
 9
10# A list of files used during training.
11train_files = [
12"path/to/train_file_1_input_A.h5",
13"path/to/train_file_2_input_A.h5",
14]
15
16# A list of files used during valdation. Per default, validation will be
17# a part of the training process, so these are required to train a model.
18validation_files = [
19"path/to/val_file_1_input_A.h5",
20]
21
22# An optional list of files to apply trained models on. Instead of giving
23# explicit filepaths, one can also give a directory containing all the h5 files:
24inference_files = [
25"path/to/inference_files_input_A/",
26]
27
28# Another input set, e.g. for a second input layer of the model.
29# Each input must have the same number of training, validation,
30# and/or inference files.
31[input_B]
32train_files = [
33"path/to/train_file_1_input_B.h5",
34"path/to/train_file_2_input_B.h5",
35]
36
37validation_files = [
38"path/to/val_file_1_input_B.h5",
39]
40
41inference_files = [
42"path/to/inference_files_input_B/",
43]

config_file

An important paramter of the config files are the modifiers. Check out Modifiers for more info. You can find various built-in modifiers in orcanet.lib.

examples/config.toml
 1# Example configuration file for OrcaNet
 2#
 3# These options define the various configurable setting of the Organizer.
 4# Possible options, together with their default values, are listed in the
 5# doc of orcanet.core.Configuration.
 6#
 7
 8[config]
 9# Batchsize that will be used for the training and validation of the network
10batchsize=32
11# The learning rate for the training. Here, it is a float, so the
12# learning rate will be constantly this value.
13learning_rate=0.002
14# shuffle the order at which the batches are read from the training files
15shuffle_train = true
16# Use a special sample modifer that is used for EdgeConv networks.
17sample_modifier="GraphEdgeConv"
18# 'GraphEdgeConv' also has optional arguments. They can be set e.g. like this:
19# sample_modifier={name=”GraphEdgeConv”, with_lightspeed=False}
20# the same syntax is also used for label modifiers and dataset modifiers.

toml files for the model builder

Models can be built with OrcaNet using a toml file. The path is handed over as the model_file argument of orcanet.model_builder.ModelBuilder. You can find various built-in layer blocks in orcanet.builder_util.layer_blocks, and some built-in losses in orcanet.lib.losses.

from orcanet.model_builder import ModelBuilder

mb = ModelBuilder(model_file="model.toml")
model = mb.build(organizer)

Here is an example for the proper file format (See Example models for more examples):

examples/model_files/explanation.toml
 1# Info for building a model with the ModelBuilder. This will produce a
 2# compiled keras model, with the input shape adapted to the input data given
 3# to the Organizer.
 4# Using this class to build a model is not required to use orca_train,
 5# as any model can be used for that.
 6#
 7# The model itself consists of a
 8# sequence of predefined layer blocks. E.g., the model might consist of convolutional
 9# layer blocks (convolution, BatchNorm, Activation, MaxPooling and/or Dropout),
10# and end with a special last block, e.g. a flatten layer followed by some dense layer blocks,
11# which produce a categorical output.
12#
13# Info for compiling the model is given in the section [compile]. This includes
14# the used optimizer (e.g. adam) and the loss functions for each output
15# of the network.
16
17# ----------------------------------------------------------------------
18[model]
19# First, the default values for the layer blocks of the network. If a
20# layer block has this parameter, its default is set to the given value
21# (kwargs are not resolved).
22#
23# Type of the block to be added, mandatory for any block
24# See orcanet/builder_util/layer_blocks.py for all available blocks, as well
25# as their possible arguments.
26type = "ConvBlock"
27# Specifies the dimension of convolutional blocks, either 1, 2 or 3
28conv_dim = 3
29# Kernel size of the convolution.
30kernel_size = 3
31# Add a dropout layer with given rate.
32dropout = 0.2
33# Pool size of a MaxPooling layer, e.g. (1,1,2)
34# pool_sizes = 2
35# Activation function that should be used. e.g. 'linear', 'relu'...
36activation = 'relu'
37# Add a batch normalization layer
38batchnorm=true
39# l2 regularizer for the weights of the layer.
40# kernel_l2_reg = 0.00001
41
42
43# Then, the blocks in the body section of the resulting network.
44# Each dict makes a new block. These will overwrite the default values from above.
45blocks = [
46    {filters=64},
47    {filters=64},
48    {filters=64, pool_size=[2, 2, 2]},
49    {filters=64},
50    {filters=64},
51    {filters=64},
52    {filters=128, pool_size=[2, 2, 2]},
53    {filters=128},
54    {filters=128},
55    {filters=128, dropout=0.0},
56    # This is the last layer of the network. In this case, its a special output block
57    # called 'OutputReg. It has 3 dense layer blocks, followed by one dense layer
58    # for each output_name.
59    # Other (output) blocks are also available, see orcanet/builder_util/layer_blocks.py
60    {type="OutputReg", output_name='direction_xyz', output_neurons=3}
61]
62
63# ----------------------------------------------------------------------
64[compile]
65# Options for the compilation of the network
66# The optimizer to use for compiling, either 'adam' or 'sgd' for predefined
67# orca optimizers, or keras:XXX for keras optimizers
68optimizer = "adam"  # or e.g. keras:Adam
69# Settings for the optimizer
70epsilon=0.1
71
72[compile.losses]
73# The loss(es) of the model are listed here.
74# Each entry is the name of the respective layer in the model, for which
75# this loss is used. The value is a dict with the following keys:
76# 'function': loss function to it will use
77# 'metrics' : list of metrics to use (optional)
78# 'weight' : weight for this loss, useful when using multiple outputs (optional)
79direction_xyz = {function="mse", metrics=["mae",], weight=1.0}