crested.tl.zoo.utils.conv_block_bs

Contents

crested.tl.zoo.utils.conv_block_bs#

crested.tl.zoo.utils.conv_block_bs(inputs, filters=None, kernel_size=1, pool_size=1, batch_norm=False, activation='relu', activation_end=None, dropout=0, residual=False, strides=1, dilation_rate=1, l2_scale=0, conv_type='standard', conv_bias=True, pool_type='max', bn_momentum=0.99, bn_gamma=None, bn_sync=True, bn_epsilon=1e-05, kernel_initializer='he_normal', padding='same', name_prefix=None)#

Construct a convolution block (for Basenji/Enformer).

Important note: while conv_block() follows the conv-norm-activate-pool order, this follows Enformer/Borzoi’s convention of norm-activate-conv-pool.

Parameters:
  • inputs – Input tensor.

  • filters (int | None (default: None)) – Conv1D filters.

  • kernel_size (int (default: 1)) – Conv1D kernel_size.

  • pool_size (int (default: 1)) – Max pool width.

  • batch_norm (bool (default: False)) – Apply batch normalization.

  • activation (str (default: 'relu')) – Activation function.

  • activation_end (str | None (default: None)) – Activation to add at end of block, after residual and before pooling. Optional, can be None to disable.

  • dropout (float (default: 0)) – Dropout rate probability.

  • residual (bool (default: False)) – Residual connection boolean.

  • strides (int (default: 1)) – Conv1D strides.

  • dilation_rate (int (default: 1)) – Conv1D dilation rate.

  • l2_scale (float (default: 0)) – L2 regularization weight.

  • conv_type (str (default: 'standard')) – Conv1D layer type.

  • conv_bias (bool (default: True)) – Whether to use a bias in the convolution layer. Should be True for Enformer/Borzoi and (maybe) False for Borzoi?

  • pool_type (str (default: 'max')) – Pooling type. Either ‘max’ or ‘attention’.

  • bn_momentum (float (default: 0.99)) – BatchNorm momentum.

  • bn_gamma (KerasTensor | None (default: None)) – BatchNorm gamma (defaults according to residual).

  • bn_sync (str (default: True)) – Whether to synchronise the batchnorm when doing multi-GPU training.

  • bn_epsilon (float (default: 1e-05)) – Epsilon to use for the BatchNorm layer. Usual default is 1e-5, but Borzoi uses 1e-3.

  • kernel_initializer (str (default: 'he_normal')) – Convolution kernel initializer.

  • padding (str (default: 'same')) – Padding type.

  • name_prefix (str | None (default: None)) – Prefix for layer names.

Return type:

KerasTensor

Returns:

Output tensor after applying the convolution block.