4.2.32. veles.znicz.standard_workflow module

Created on May 5, 2014

Standard workflow class definition.

███████████████████████████████████████████████████████████████████████████████

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

███████████████████████████████████████████████████████████████████████████████

class BaseWorkflowConfig

Bases: builtins.tuple

BaseWorkflowConfig(loader,)

loader

Alias for field number 0

class ForwardWorkflowExtractor(workflow, **kwargs)[source]

Bases: veles.units.Unit, veles.distributable.TriviallyDistributable

Class to extract core of Neural Network without back propagation.

KWATTRS = {'name', 'view_group', 'result_unit_factory', 'generate_data_for_slave_threadsafe', 'timings', 'logger', 'ignore_gate', 'loader_name', 'apply_data_from_slave_threadsafe', 'loader_config', 'cyclic'}
class GradientUnitFactory[source]

Bases: builtins.object

This factory makes GradientDescentBase-interfaced units
according to their forward-prop units.
static create(fwd, name, **kwargs)[source]

Creates gradient descent unit by forward prop unit.

Parameters:
  • fwd (Unit) – a forward propagation unit
  • bias_learning_rate (float) – uses learning_rate if not set
  • bias_weight_decay (float) – uses weight_decay if not set
  • momentum (float) – 0 by default
  • bias_momentum (float) – uses momentum if not set
Returns:

GradientDescentBase: a specific grad unit for fwd_prop

class StandardWorkflow(workflow, **kwargs)[source]

Bases: veles.znicz.standard_workflow.StandardWorkflowBase

Workflow for trivially connections between Unit. User can create Self-constructing Models with that class. It means that User can change structure of Model (Convolutional, Fully connected, different parameters) and parameters of training in configuration file.

Parameters:
  • loss_function – name of Loss function. Choices are “softmax” or “mse”
  • decision_name – name of Decision. If loss_function was defined and decision_name was not, decision_name creates automaticly
  • evaluator_name – name of Evaluator. If loss_function was defined and evaluator_name was not, evaluator_name creates automaticly
  • decision_config – decision configuration parameters
  • snapshotter_config – snapshotter configuration parameters
  • image_save_configr – image_saver configuration parameters
  • data_saver_config – data_saver configuration parameters
  • result_loader_config – result_loader configuration parameters
  • similar_weights_plotter_config – similar_weights_plotter configuration parameters
  • result_loader_name – The forward workflow’s loader name. Not neccessary if forward workflow is not going to be extracted.
  • result_unit_factory – The results’ publishing unit factory.
CONFIGURABLE_UNIT_NAMES = ('result_loader', 'decision', 'evaluator', 'snapshotter')
KWATTRS = {'name', 'weights_plotter_config', 'image_saver_config', 'view_group', 'decision_config', 'result_unit_factory', '%s_name', 'snapshotter_config', 'preprocessing', 'result_file', 'layers', 'result_loader_name', 'sync', 'snapshotter_name', 'generate_data_for_slave_threadsafe', 'timings', 'logger', 'rollback_config', 'publisher_config', 'ignore_gate', 'loader_name', 'lr_adjuster_config', 'downloader_config', 'loader_config', 'enable_plotters', 'apply_data_from_slave_threadsafe', 'result_loader_config', 'evaluator_name', 'power_measure_time_interval', 'mcdnnic_parameters', 'loss_function', 'mcdnnic_topology', 'data_saver_config', 'loader_factory', 'similar_weights_plotter_config', 'evaluator_config', 'decision_name'}
WorkflowConfig

alias of StandardWorkflowConfig

extract_forward_workflow(loader_unit_factory=None, loader_name=None, loader_config=None, result_unit_factory=None, result_unit_config=None, cyclic=True)[source]

Generates a separate forward propagation workflow from this one, taking the trained weights, settings, etc. :param loader_unit_factory: callable(workflow) which returns the loader unit. :param loader_name: Alternative to loader_unit_factory, loader name in UserLoaderRegistry. :param loader_config: Used in pair with loader_name to configure the loader. May be a dictionary or an instance of veles.config.Config. :param result_unit_factory: callable(workflow) which returns the result output unit. :param result_unit_config: Passed into result_unit_factory as keyword arguments. May be a dictionary or an instance of veles.config.Config. :param cyclic: True if the loader decides whether to stop the workflow; otherwise, False => the extracted workflow is going to do a single iteration. :return: veles.znicz.standard_workflow.StandardWorkflowBase instance.

Replaces the current loader with it’s avatar, allowing the parallel work of the loader and the main contour. Please note that the loader must be linked from the start point, not the repeater. :param extra_attrs: Additional attributes to copy from the loader. :return: The linked veles.avatar.Avatar unit.

Creates the list of instances of veles.plotting_units.MatrixPlotter. Links the first veles.plotting_units.MatrixPlotter unit with *parents. Links each veles.plotting_units.MatrixPlotter unit from previous veles.plotting_units.MatrixPlotter unit. Links attributes of veles.plotting_units.MatrixPlotter units from attributes of veles.znicz.decision.DecisionBase cd descendant. Returns the last of veles.plotting_units.MatrixPlotter units.

Parameters:parents – units, from whom will be link the first of veles.plotting_units.MatrixPlotter units.

Links the existing veles.workflow.EndPoint unit with *parents. Returns veles.workflow.EndPoint instance.

Parameters:parents – units to link this one from.

Creates the list of instances of veles.plotting_units.AccumulatingPlotter. Links the first veles.plotting_units.AccumulatingPlotter unit with *parents. Links each veles.plotting_units.AccumulatingPlotter unit from previous veles.plotting_units.AccumulatingPlotter unit. Links attributes of veles.plotting_units.AccumulatingPlotter units from attributes of veles.znicz.decision.DecisionBase descendant (max_err_y_sums). Returns the last instance of veles.plotting_units.AccumulatingPlotter.

Parameters:parents – units, from whom will be link the first of veles.plotting_units.AccumulatingPlotter units.

Closes the loop based on the veles.workflow.Repeater.

Parameters:parent – unit, from whom will be link veles.workflow.Repeater unit

Creates the list of instances of veles.plotting_units.AccumulatingPlotter. Links the first veles.plotting_units.AccumulatingPlotter unit with *parents. Links each veles.plotting_units.AccumulatingPlotter unit from previous veles.plotting_units.AccumulatingPlotter unit. Links attributes of veles.plotting_units.AccumulatingPlotter units from attributes of veles.znicz.decision.DecisionBase descendant (epoch_metrics). Returns the last instance of veles.plotting_units.AccumulatingPlotter. :param is_min: True if linking min plotter, otherwise, False for max. :param parents: units, from whom will be link the first of veles.plotting_units.AccumulatingPlotter units.

Creates the list of instances of veles.plotting_units.AccumulatingPlotter. Links the first veles.plotting_units.AccumulatingPlotter unit with *parents. Links each veles.plotting_units.AccumulatingPlotter unit from previous veles.plotting_units.AccumulatingPlotter unit. Links attributes of veles.plotting_units.AccumulatingPlotter units from attributes of veles.znicz.decision.DecisionBase descendant (epoch_metrics). Returns the last instance of veles.plotting_units.AccumulatingPlotter.

Parameters:parents – units, from whom will be link the first of veles.plotting_units.AccumulatingPlotter units.

Creates the list of instances of veles.plotting_units.MultiHistogram units. Links the first veles.plotting_units.MultiHistogram unit with *parents. Links each veles.plotting_units.MultiHistogram unit from previous veles.plotting_units.MultiHistogram unit. Links attributes of veles.plotting_units.MultiHistogram units from attributes of veles.znicz.decision.DecisionBase descendant. Returns the last veles.plotting_units.MultiHistogram unit.

Parameters:
  • weights_input – weights to plotting. “weights” or “gradient_weights” for example
  • limit – max number of pictures on one plotter
  • parents – units, from whom will be link the first of veles.plotting_units.MultiHistogram units.

Creates instance of veles.znicz.standard_workflow.ForwardWorkflowExtractor unit. Links veles.znicz.decision.DecisionBase descendant from veles.znicz.standard_workflow.ForwardWorkflowExtractor. Returns instance of veles.znicz.standard_workflow.ForwardWorkflowExtractor.

Creates the list of instances of veles.znicz.diversity.SimilarWeights2D units. Links the first veles.znicz.diversity.SimilarWeights2D unit with *parents. Links each veles.znicz.diversity.SimilarWeights2D unit from previous veles.znicz.diversity.SimilarWeights2D unit. Links attributes of veles.znicz.diversity.SimilarWeights2D units from attributes of veles.znicz.decision.DecisionBase descendant, veles.loader.base.Loader descendant, veles.znicz.nn_units.ForwardBase descendant and veles.znicz.nn_plotting_units.Weights2D unit. Returns the last of veles.znicz.diversity.SimilarWeights2D units.

Parameters:
  • weights_input – weights to plotting. “weights” or “gradient_weights” for example
  • parents – units, from whom will be link the first of veles.znicz.diversity.SimilarWeights2D units.
class StandardWorkflowBase(workflow, **kwargs)[source]

Bases: veles.znicz.nn_units.NNWorkflow

A base class for standard workflows with forward and backward propagation. Is able to automatically create backward units by pre-created forward units

Parameters:
  • layers – list of dictionary with layers of Model
  • loader_name – name of the Loader. If loader_name is None, User should redefine link_loader() function and link Loader manually.
  • loader_config – loader configuration parameters
KWATTRS = {'enable_plotters', 'loader_config', 'name', 'apply_data_from_slave_threadsafe', 'view_group', 'power_measure_time_interval', 'result_file', 'preprocessing', 'mcdnnic_parameters', 'layers', 'sync', 'mcdnnic_topology', 'generate_data_for_slave_threadsafe', 'timings', 'logger', 'loader_factory', 'ignore_gate', 'loader_name'}
WorkflowConfig

alias of BaseWorkflowConfig

Links the existing veles.workflow.EndPoint and veles.workflow.Repeater with *parents. Returns veles.workflow.EndPoint instance.

Parameters:parents – units to link this one from.

Links veles.plumbing.FireStarter instance from *parents. Returns veles.plumbing.FireStarter instance.

Parameters:parents – units to link this one from.

Creates forward units ( veles.znicz.nn_units.ForwardBase descendant) from “layers” configuration. Links first forward unit from *parents argument. Links init_attrs argument with first forward unit attributes. For each layer adds a new forward unit to self.forwards, links it with the previous forward unit by veles.units.Unit.link_from() . Links attributes of that unit with attributes of the previous forward unit by veles.units.Unit.link_attrs() . Returns the last of veles.znicz.nn_units.ForwardBase descendant units.

Parameters:
  • init_attrs – attrubutes of parents unit, which will be transfer to first forward unit
  • parents – units, from whom will be link first forward unit

Creates a new veles.loader.base.Loader descendant. The actual class type is taken from the global mapping by “loader_name” key. Links veles.loader.base.Loader descendant from *parents. Returns veles.loader.base.Loader descendant instance.

Parameters:parents – units to link this one from.

Links veles.workflow.Repeater instance from *parents. Returns veles.workflow.Repeater instance.

Parameters:parents – units to link this one from.
mcdnnic_layer_patern = re.compile('(?P<C>\\d+C\\d+)|(?P<MP>MP\\d+)|(?P<N>\\d+N)')
mcdnnic_parse_methods = {}
mcdnnic_topology_regexp = re.compile('(\\d+)x(\\d+)x(\\d+)(-(?:(\\d+C\\d+)|(MP\\d+)|(\\d+N)))*')
class StandardWorkflowConfig

Bases: builtins.tuple

StandardWorkflowConfig(decision, snapshotter, image_saver, evaluator, data_saver, result_loader, weights_plotter, similar_weights_plotter, lr_adjuster, downloader, publisher, rollback, loader)

data_saver

Alias for field number 4

decision

Alias for field number 0

downloader

Alias for field number 9

evaluator

Alias for field number 3

image_saver

Alias for field number 2

loader

Alias for field number 12

lr_adjuster

Alias for field number 8

publisher

Alias for field number 10

result_loader

Alias for field number 5

rollback

Alias for field number 11

similar_weights_plotter

Alias for field number 7

snapshotter

Alias for field number 1

weights_plotter

Alias for field number 6

class TypeDict(dict=None, **kwargs)[source]

Bases: collections.UserDict

All keys in the dictionary must be classes. Its [key] operator looks up
the key inheritance hierarchy and chooses its nearest ancestor as a key to return its coupled value.

Previous topic

4.2.31. veles.znicz.site_config module

Next topic

4.2.33. veles.znicz.standard_workflow_base module

This Page