8.1.1.7.2.1. blueoil.networks.base

8.1.1.7.2.1.1. Module Contents

8.1.1.7.2.1.1.1. Classes

BaseNetwork

Base network.

class blueoil.networks.base.BaseNetwork(is_debug=False, optimizer_class=tf.compat.v1.train.GradientDescentOptimizer, optimizer_kwargs=None, learning_rate_func=None, learning_rate_kwargs=None, classes=(), image_size=(), batch_size=64, data_format='NHWC')

Bases: object

Base network.

This base network is for every task, such as classification, object detection and segmentation. Every sub task’s base network class should extend this class.

Parameters
  • is_debug (boolean) – Set True to use debug mode. It will summary some histograms, use small dataset and step size.

  • optimizer_class (class) – Optimizer using for training.

  • optimizer_kwargs (dict) – For init optimizer.

  • learning_rate_func (callable) – Use for changing learning rate. Such as learning rate decay, tf.train.piecewise_constant.

  • learning_rate_kwargs (dict) – For learning rate function. For example of tf.train.piecewise_constant, {“values”: [5e-5, 1e-5, 5e-6, 1e-6, 5e-7], “boundaries”: [20000, 40000, 60000, 80000]}.

  • classes (list | tuple) – Classes names list.

  • image_size (list | tuple) – Image size.

  • batch_size (list | tuple) – Batch size.

abstract base(self, images, is_training, *args, **kwargs)

Base function contains inference.

Parameters
  • images – Input images.

  • is_training – A flag for if is training.

Returns

Inference result.

Return type

tf.Tensor

abstract placeholders(self)

Placeholders.

Return placeholders.

Returns

Placeholders.

Return type

tf.compat.v1.placeholder

abstract metrics(self, output, labels)

Metrics.

Parameters
  • output – tensor from inference.

  • labels – labels tensor.

summary(self, output, labels=None)

Summary.

Parameters
  • output – tensor from inference.

  • labels – labels tensor.

abstract inference(self, images, is_training)

Inference.

Parameters

images – images tensor. shape is (batch_num, height, width, channel)

abstract loss(self, output, labels)

Loss.

Parameters
  • output – tensor from inference.

  • labels – labels tensor.

optimizer(self)
train(self, loss, optimizer, var_list=[])

Train.

Parameters

loss – loss function of this network.