Mercurial > repos > bgruening > sklearn_regression_metrics
comparison keras_deep_learning.py @ 27:95a37d463eac draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 208a8d348e7c7a182cfbe1b6f17868146428a7e2"
| author | bgruening |
|---|---|
| date | Tue, 13 Apr 2021 20:55:18 +0000 |
| parents | fe37e4c07643 |
| children | 842d9c59b6b7 |
comparison
equal
deleted
inserted
replaced
| 26:fa0e99359ba8 | 27:95a37d463eac |
|---|---|
| 1 import argparse | 1 import argparse |
| 2 import json | 2 import json |
| 3 import pickle | |
| 4 import warnings | |
| 5 from ast import literal_eval | |
| 6 | |
| 3 import keras | 7 import keras |
| 4 import pandas as pd | 8 import pandas as pd |
| 5 import pickle | |
| 6 import six | 9 import six |
| 7 import warnings | 10 from galaxy_ml.utils import get_search_params, SafeEval, try_get_attr |
| 8 | 11 from keras.models import Model, Sequential |
| 9 from ast import literal_eval | |
| 10 from keras.models import Sequential, Model | |
| 11 from galaxy_ml.utils import try_get_attr, get_search_params, SafeEval | |
| 12 | 12 |
| 13 | 13 |
| 14 safe_eval = SafeEval() | 14 safe_eval = SafeEval() |
| 15 | 15 |
| 16 | 16 |
| 175 options.update(kwargs) | 175 options.update(kwargs) |
| 176 | 176 |
| 177 # merge layers | 177 # merge layers |
| 178 if 'merging_layers' in options: | 178 if 'merging_layers' in options: |
| 179 idxs = literal_eval(options.pop('merging_layers')) | 179 idxs = literal_eval(options.pop('merging_layers')) |
| 180 merging_layers = [all_layers[i-1] for i in idxs] | 180 merging_layers = [all_layers[i - 1] for i in idxs] |
| 181 new_layer = klass(**options)(merging_layers) | 181 new_layer = klass(**options)(merging_layers) |
| 182 # non-input layers | 182 # non-input layers |
| 183 elif inbound_nodes is not None: | 183 elif inbound_nodes is not None: |
| 184 new_layer = klass(**options)(all_layers[inbound_nodes-1]) | 184 new_layer = klass(**options)(all_layers[inbound_nodes - 1]) |
| 185 # input layers | 185 # input layers |
| 186 else: | 186 else: |
| 187 new_layer = klass(**options) | 187 new_layer = klass(**options) |
| 188 | 188 |
| 189 all_layers.append(new_layer) | 189 all_layers.append(new_layer) |
| 190 | 190 |
| 191 input_indexes = _handle_shape(config['input_layers']) | 191 input_indexes = _handle_shape(config['input_layers']) |
| 192 input_layers = [all_layers[i-1] for i in input_indexes] | 192 input_layers = [all_layers[i - 1] for i in input_indexes] |
| 193 | 193 |
| 194 output_indexes = _handle_shape(config['output_layers']) | 194 output_indexes = _handle_shape(config['output_layers']) |
| 195 output_layers = [all_layers[i-1] for i in output_indexes] | 195 output_layers = [all_layers[i - 1] for i in output_indexes] |
| 196 | 196 |
| 197 return Model(inputs=input_layers, outputs=output_layers) | 197 return Model(inputs=input_layers, outputs=output_layers) |
| 198 | 198 |
| 199 | 199 |
| 200 def get_batch_generator(config): | 200 def get_batch_generator(config): |
| 298 ['optimizer_selection']['optimizer_type']).lower() | 298 ['optimizer_selection']['optimizer_type']).lower() |
| 299 | 299 |
| 300 options.update((inputs['mode_selection']['compile_params'] | 300 options.update((inputs['mode_selection']['compile_params'] |
| 301 ['optimizer_selection']['optimizer_options'])) | 301 ['optimizer_selection']['optimizer_options'])) |
| 302 | 302 |
| 303 train_metrics = (inputs['mode_selection']['compile_params'] | 303 train_metrics = inputs['mode_selection']['compile_params']['metrics'] |
| 304 ['metrics']).split(',') | |
| 305 if train_metrics[-1] == 'none': | 304 if train_metrics[-1] == 'none': |
| 306 train_metrics = train_metrics[:-1] | 305 train_metrics = train_metrics[:-1] |
| 307 options['metrics'] = train_metrics | 306 options['metrics'] = train_metrics |
| 308 | 307 |
| 309 options.update(inputs['mode_selection']['fit_params']) | 308 options.update(inputs['mode_selection']['fit_params']) |
