:py:mod:`orcanet.model_builder` =============================== .. py:module:: orcanet.model_builder .. autoapi-nested-parse:: Scripts for making specific models. .. !! processed by numpydoc !! Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: orcanet.model_builder.ModelBuilder Functions ~~~~~~~~~ .. autoapisummary:: orcanet.model_builder.get_adam orcanet.model_builder.get_sgd .. py:class:: ModelBuilder(model_file, **custom_blocks) Build and compile a keras model from a toml file, using OrcaNet building blocks. The input of the model can match the dimensions of the input data given to the Organizer taking into account the sample modifier. :Attributes: **configs** : list List with keywords for building each layer block in the model. **defaults** : dict Default values for the layer blocks in the model. **optimizer** : str or Optimizer Optimizer for training the model. Can be a string like "adam" (or "keras:adam" for the default keras variant), or an object derived from ks.optimizers.Optimizer. **compile_opt** : dict Keys: Names of the output layers of the model. Values: Loss function, optionally weight and optionally metric of each output layer. Format: { layer_name : { loss_function:, weight:, metrics: } } The loss_function is a string or a function, the weight is a float and metrics is a list of functions/strings. **optimizer_args** : dict, optional Kwargs for the optimizer. Not used when an optimizer object is given. **input_opts** : dict Specify options for the input of the model. .. rubric:: Methods ==================== ========== **build** Build the network using an instance of Organizer. **build_with_input** Build the network without an Organizer, just using given input shapes. **compile** Compile a model with the optimizer settings given in the model_file. ==================== ========== .. !! processed by numpydoc !! .. py:method:: build(orga, log_comp_opts=False, verbose=False) Build the network using an instance of Organizer. Input layers will be adapted to the input files in the organizer. Can also add the matching modifiers and custom objects to the orga. :Parameters: **orga** : orcanet.core.Organizer Contains all the configurable options in the OrcaNet scripts. **log_comp_opts** : bool If the info used for the compilation of the model should be logged to the log.txt. **verbose** : bool Print info about the building process? :Returns: **model** : keras model The network. .. !! processed by numpydoc !! .. py:method:: build_with_input(input_shapes, compile_model=True, custom_objects=None, verbose=False) Build the network with given input shapes. :Parameters: **input_shapes** : dict Keys: Name of the inputs of the model. Values: Their shape without the batchsize. **compile_model** : bool Compile the model? **custom_objects** : dict, optional Custom objects to use during compiling. **verbose** : bool Print info about the building process? :Returns: **model** : ks.Model The network. .. !! processed by numpydoc !! .. py:method:: compile_model(model, custom_objects=None) Compile a model with the optimizer settings given as the attributes. :Parameters: **model** : ks.model A keras model. **custom_objects** : dict or None Maps names (strings) to custom loss functions. :Returns: **model** : keras model The compiled (or recompiled) keras model. .. !! processed by numpydoc !! .. py:method:: log_model_properties(orga) Writes the compile_opt config to the full log file. .. !! processed by numpydoc !! .. py:function:: get_adam(beta_1=0.9, beta_2=0.999, epsilon=0.1, decay=0.0, **kwargs) .. py:function:: get_sgd(momentum=0.9, decay=0, nesterov=True, **kwargs)