pytoolkit.layers package

Submodules

pytoolkit.layers.activations module

カスタムレイヤー。

class pytoolkit.layers.activations.DropActivation(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Drop-Activation <https://arxiv.org/abs/1811.05850>

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, training=None)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.attentions module

カスタムレイヤー。

class pytoolkit.layers.attentions.PositionalEncoding(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Positional Encodingレイヤー。

x(i) = pos / pow(10000, 2 * i / depth) PE(pos, 2 * i) = sin(x(i)) PE(pos, 2 * i + 1) = cos(x(i))

↑これを入力に足す。

→ 偶数・奇数で分けるのがやや面倒なので、depthの最初半分がsin, 後ろ半分がcosになるようにする

&& depthは偶数前提にしてしまう

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.attentions.MultiHeadAttention(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Multi-head Attetion

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.attentions.MultiHeadAttention2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Multi-head Attetionの2D版のようなもの。(怪)

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.blocks module

複数のレイヤーを組み合わせたブロック。

save/loadのトラブルなどを考えて基本的にFunctional API。

pytoolkit.layers.blocks.se_block(ratio=4)[ソース]

Squeeze-and-Excitation block with swish。<https://arxiv.org/abs/1709.01507>

パラメータ

ratio (int) --

pytoolkit.layers.convolutional module

カスタムレイヤー。

class pytoolkit.layers.convolutional.CoordChannel1D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

CoordConvなレイヤー。

■[1807.03247] An Intriguing Failing of Convolutional Neural Networks and the CoordConv Solution https://arxiv.org/abs/1807.03247

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.convolutional.CoordChannel2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

CoordConvなレイヤー。

■[1807.03247] An Intriguing Failing of Convolutional Neural Networks and the CoordConv Solution https://arxiv.org/abs/1807.03247

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.convolutional.WSConv2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.layers.convolutional.Conv2D

Weight StandardizationなConv2D <https://arxiv.org/abs/1903.10520>

call(inputs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.convolutional.CoordEmbedding2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

CoordConvのようなものでチャンネル数を増やさないようにしてみたもの。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.endpoint module

カスタムレイヤー。

class pytoolkit.layers.endpoint.AutomatedFocalLoss(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Automated Focal Loss <https://arxiv.org/abs/1904.09048>

ラベルとsigmoid/softmaxの前の値を受け取り、損失の値を返す。

パラメータ
  • mode -- "binary" or "categorical"

  • class_weights -- 各クラスの重み (不要ならNone)

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.misc module

カスタムレイヤー。

class pytoolkit.layers.misc.ConvertColor(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

ColorNet <https://arxiv.org/abs/1902.00267> 用の色変換とついでにスケーリング。

入力は[0, 255]、出力はモード次第だが-3 ~ +3程度。

パラメータ

mode -- 'rgb_to_rgb' 'rgb_to_lab' 'rgb_to_hsv' 'rgb_to_yuv' 'rgb_to_ycbcr' 'rgb_to_hed' 'rgb_to_yiq' のいずれか。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.misc.RemoveMask(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

マスクを取り除く。

compute_mask(inputs, mask=None)[ソース]

Computes an output mask tensor.

パラメータ
  • inputs -- Tensor or list of tensors.

  • mask -- Tensor or list of tensors.

戻り値

None or a tensor (or list of tensors,

one per output tensor of the layer).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.misc.ChannelPair2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

チャンネル同士の2個の組み合わせの積。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.misc.ScaleValue(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

値だけをスケーリングしてシフトするレイヤー。回帰の出力前とかに。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.misc.ScaleGradient(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

勾配だけをスケーリングするレイヤー。転移学習するときとかに。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.misc.ImputeNaN(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

NaNを適当な値に変換する層。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.misc.TrainOnly(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.layers.wrappers.Wrapper

訓練時のみ適用するlayer wrapper

call(inputs, training=None, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.misc.TestOnly(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.layers.wrappers.Wrapper

推論時のみ適用するlayer wrapper

call(inputs, training=None, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

class pytoolkit.layers.misc.Scale(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

学習可能なスケール値。

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.misc.RandomScale(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

ランダムにスケーリング

パラメータ
  • min_scale -- 最小値

  • max_scale -- 最大値

  • shape -- スケールのshape

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.noise module

カスタムレイヤー。

class pytoolkit.layers.noise.MixFeat(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

MixFeat <https://openreview.net/forum?id=HygT9oRqFX>

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, training=None)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.noise.DropBlock2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

DropBlock <https://arxiv.org/abs/1810.12890>

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, training=None, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.normalization module

カスタムレイヤー。

class pytoolkit.layers.normalization.SyncBatchNormalization(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Sync BN。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, training=None, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.normalization.GroupNormalization(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Group Normalization。

パラメータ

groups -- グループ数

参照

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.normalization.InstanceNormalization(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Instance Normalization

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.normalization.RMSNormalization(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Root Mean Square Layer Normalization <https://arxiv.org/abs/1910.07467>

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.normalization.RandomRMSNormalization(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

ランダム要素のあるrmsを使ったnormalization。<https://twitter.com/ak11/status/1202838201716490240>

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs, training=None, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

pytoolkit.layers.pooling module

カスタムレイヤー。

class pytoolkit.layers.pooling.Resize2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

リサイズ。

パラメータ
  • size -- (new_height, new_width)

  • scale -- float (sizeと排他でどちらか必須)

  • interpolation -- 'bilinear', 'nearest', 'bicubic', 'lanczos3', 'lanczos5', 'area'

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.ParallelGridPooling2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Parallel Grid Poolingレイヤー。

■ Parallel Grid Pooling for Data Augmentation https://arxiv.org/abs/1803.11370

■ akitotakeki/pgp-chainer: Chainer Implementation of Parallel Grid Pooling for Data Augmentation https://github.com/akitotakeki/pgp-chainer

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.ParallelGridGather(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

ParallelGridPoolingでparallelにしたのを戻すレイヤー。

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.SubpixelConv2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Sub-Pixel Convolutional Layer。

■ Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network https://arxiv.org/abs/1609.05158

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.BlurPooling2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Blur Pooling Layer <https://arxiv.org/abs/1904.11486>

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.GeM2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Generalized Mean Pooling (GeM) <https://github.com/filipradenovic/cnnimageretrieval-pytorch>

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

class pytoolkit.layers.pooling.GeMPooling2D(*args, **kwargs)[ソース]

ベースクラス: tensorflow.python.keras.engine.base_layer.Layer

Generalized Mean Pooling (GeM)

参照

build(input_shape)[ソース]

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

パラメータ

input_shape -- Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

compute_output_shape(input_shape)[ソース]

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

パラメータ

input_shape -- Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

戻り値

An input shape tuple.

call(inputs, **kwargs)[ソース]

This is where the layer's logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

パラメータ
  • inputs -- Input tensor, or list/tuple of input tensors.

  • *args -- Additional positional arguments. Currently unused.

  • **kwargs -- Additional keyword arguments. Currently unused.

戻り値

A tensor or list/tuple of tensors.

get_config()[ソース]

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

戻り値

Python dictionary.

Module contents

カスタムレイヤー。