view keras_model_builder.xml @ 14:624e2afa1313 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
author bgruening
date Wed, 09 Aug 2023 13:26:02 +0000
parents 449a757be9c9
children
line wrap: on
line source

<tool id="keras_model_builder" name="Create deep learning model" version="@VERSION@" profile="@PROFILE@">
    <description>with an optimizer, loss function and fit parameters</description>
    <macros>
        <import>main_macros.xml</import>
        <import>keras_macros.xml</import>
    </macros>
    <expand macro="python_requirements" />
    <expand macro="macro_stdio" />
    <version_command>echo "@VERSION@"</version_command>
    <command>
        <![CDATA[
        python '$__tool_directory__/keras_deep_learning.py'
                --inputs '$inputs'
                --tool_id 'keras_model_builder'
                --outfile '$outfile'
                --model_json '$mode_selection.infile_json'
        ]]>
    </command>
    <configfiles>
        <inputs name="inputs" />
    </configfiles>
    <inputs>
        <conditional name="mode_selection">
            <param name="mode_type" type="select" label="Choose a building mode">
                <option value="train_model" selected="true">Build a training model</option>
                <!--option value="prefitted">Load a pretrained model for prediction</option>-->
            </param>
            <when value="train_model">
                <param name="infile_json" type="data" format="json" label="Select the dataset containing model configurations (JSON)" />
                <param name="learning_type" type="select" label="Do classification or regression?">
                    <option value="KerasGClassifier">KerasGClassifier</option>
                    <option value="KerasGRegressor">KerasGRegressor</option>
                </param>
                <expand macro="keras_compile_params_section" />
                <expand macro="keras_fit_params_section">
                    <param name="validation_split" type="float" value="0.1" optional="true" label="The proportion of training data to set aside as validation set." help="Will be ignored if `validation_data` is set explicitly, such as in `Deep learning training and evaluation` tool." />
                </expand>
                <param name="random_seed" type="integer" value="" optional="true" label="Random Seed" help="Integer or blank for None. Warning: when random seed is set to an integer, training will be running in single thread mode, which may cause slowness." />
            </when>
            <!--when value="prefitted">
                <param name="infile_json" type="data" format="json" label="Select the dataset containing model configurations (JSON)" />
                <param name="infile_weights" type="data" format="h5" label="Select the dataset containing keras layers weights" />
            </when>-->
        </conditional>
    </inputs>
    <outputs>
        <data format="h5mlm" name="outfile" label="Keras Model Builder on ${on_string}" />
    </outputs>
    <tests>
        <test>
            <conditional name="mode_selection">
                <param name="infile_json" value="keras01.json" ftype="json" />
                <param name="learning_type" value="KerasGRegressor" />
                <section name="fit_params">
                    <param name="epochs" value="100" />
                </section>
            </conditional>
            <output name="outfile" file="keras_model01" compare="sim_size" delta="20" />
        </test>
        <test>
            <conditional name="mode_selection">
                <param name="infile_json" value="keras02.json" ftype="json" />
                <section name="compile_params">
                    <conditional name="optimizer_selection">
                        <param name="optimizer_type" value="Adam" />
                    </conditional>
                </section>
                <section name="fit_params">
                    <param name="epochs" value="100" />
                </section>
            </conditional>
            <output name="outfile" file="keras_model02" compare="sim_size" delta="20" />
        </test>
        <!--test>
            <conditional name="mode_selection">
                <param name="mode_type" value="prefitted" />
                <param name="infile_json" value="keras03.json" ftype="json" />
                <param name="infile_weights" value="keras_save_weights01.h5" ftype="h5" />
            </conditional>
            <output name="outfile" file="keras_prefitted01.zip" compare="sim_size" delta="5" />
        </test>-->
        <test>
            <conditional name="mode_selection">
                <param name="infile_json" value="keras04.json" ftype="json" />
                <param name="learning_type" value="KerasGRegressor" />
                <section name="compile_params">
                    <conditional name="optimizer_selection">
                        <param name="optimizer_type" value="Adam" />
                    </conditional>
                    <param name="metrics" value="mse" />
                    <param name="loss" value="mean_squared_error" />
                </section>
                <section name="fit_params">
                    <param name="epochs" value="100" />
                </section>
                <param name="random_seed" value="42" />
            </conditional>
            <output name="outfile" file="keras_model04" compare="sim_size" delta="20" />
        </test>
    </tests>
    <help>
    <![CDATA[
**Help**

**What it does**

Creates an estimator object (classifier or regressor) by using the architecture JSON from 'Create architecture' tool and adding an optimizer, loss function and other fit parameters. The fit parameters include the number of training epochs and batch size. Multiple attributes of an optimizer can also be set. A pre-trained deep learning model can also be used with this tool.

**Return**

An estimator object which can be used to train on a dataset.

**How to compile the architecture using this tool?**

1. Choose the architecture building mode. For example - choose "Build a training model".
2. Attach an architecture JSON file (obtained after executing "Create architecture" tool) which contains information about multiple layers.
3. Select a loss function. For example - for classification tasks, choose 'cross entropy' losses and for regression tasks, choose 'mean squared' or 'mean absolute' losses.
4. Choose an optimizer which minimizes the loss computed by the loss function. Multiple attributes of the chosen optimizer can be modified. 'RMSProp' and 'Adam' are some of the popular optimizers.
5. Insert the number of iterations (epochs) and the size of training batches (batch_size).
6. Execute the tool to get a compiled estimator object.

    ]]>
    </help>
    <citations>
        <expand macro="keras_citation" />
        <expand macro="tensorflow_citation" />
    </citations>
</tool>