speechbrain.nnet.complex_networks.c_ops 模块

该库实现了复数网络所需的各种操作。

这项工作受到 Trabelsi C. 等人的“Deep Complex Networks”启发。

作者
  • Titouan Parcollet 2020

概要

函数

affect_conv_init

将给定的权重初始化函数应用于参数。

affect_init

将给定的权重初始化函数应用于参数。

check_complex_input

检查线性层的复数值形状。

complex_conv_op

对输入数据应用复数卷积。

complex_init

返回一个复数矩阵,按照 Trabelsi C. 等人的“Deep Complex Networks”中的描述进行初始化。

complex_linear_op

对输入数据应用复数线性变换。

get_conjugate

返回输入复数的共轭 (z = r - xi)。

get_imag

返回复数值输入的虚部。

get_real

返回复数值输入的实部。

multi_mean

input 的多个维度执行 torch.mean

unitary_init

返回一个酉复数矩阵。

参考

speechbrain.nnet.complex_networks.c_ops.check_complex_input(input_shape)[source]

检查线性层的复数值形状。

参数:

input_shape (tuple) – 期望的输入形状。

speechbrain.nnet.complex_networks.c_ops.get_real(input, input_type='linear', channels_axis=1)[source]

返回复数值输入的实部。

参数:
  • input (torch.Tensor) – 输入张量。

  • input_type (str,) – (convolution, linear) (默认 “linear”)

  • channels_axis (int.) – 默认 1。

返回类型:

复数值输入的实部。

speechbrain.nnet.complex_networks.c_ops.get_imag(input, input_type='linear', channels_axis=1)[source]

返回复数值输入的虚部。

参数:
  • input (torch.Tensor) – 输入张量。

  • input_type (str) – (convolution, linear) (默认 “linear”)

  • channels_axis (int) – 默认 1。

返回类型:

复数值输入的虚部。

speechbrain.nnet.complex_networks.c_ops.get_conjugate(input, input_type='linear', channels_axis=1)[source]

返回输入复数的共轭 (z = r - xi)。

参数:
  • input (torch.Tensor) – 输入张量

  • input_type (str,) – (convolution, linear) (默认 “linear”)

  • channels_axis (int.) – 默认 1。

返回类型:

输入复数的共轭。

speechbrain.nnet.complex_networks.c_ops.complex_linear_op(input, real_weight, imag_weight, bias)[source]

对输入数据应用复数线性变换。

参数:
  • input (torch.Tensor) – 要转换的复数输入张量。

  • real_weight (torch.Parameter) – 此层的四元数权重矩阵的实部。

  • imag_weight (torch.Parameter) – 此层的四元数权重矩阵的第一个虚部。

  • bias (torch.Parameter)

返回类型:

应用复数线性变换后的输出。

speechbrain.nnet.complex_networks.c_ops.complex_conv_op(input, real_weight, imag_weight, bias, stride, padding, dilation, conv1d)[source]

对输入数据应用复数卷积。

参数:
  • input (torch.Tensor) – 要转换的复数输入张量。

  • real_weight (torch.Parameter) – 此层的四元数权重矩阵的实部。

  • imag_weight (torch.Parameter) – 此层的四元数权重矩阵的第一个虚部。

  • bias (torch.Parameter)

  • stride (int) – 卷积滤波器的步幅因子。

  • padding (int) – 填充量。更多信息请参阅 torch.nn 文档。

  • dilation (int) – 卷积滤波器的膨胀因子。

  • conv1d (bool) – 如果为 true,将应用 1D 卷积操作。否则,调用 2D 卷积。

返回类型:

应用复数卷积后的输出。

speechbrain.nnet.complex_networks.c_ops.unitary_init(in_features, out_features, kernel_size=None, criterion='glorot')[source]

返回一个酉复数矩阵。

参数:
  • in_features (int) – 输入层实数值的数量 (四元数 // 4)。

  • out_features (int) – 输出层实数值的数量 (四元数 // 4)。

  • kernel_size (int) – 卷积层的 Kernel_size (例如: (3,3))。

  • criterion (str) – (glorot, he) (默认 “glorot”)。

返回类型:

酉复数矩阵。

speechbrain.nnet.complex_networks.c_ops.complex_init(in_features, out_features, kernel_size=None, criterion='glorot')[source]

返回一个复数矩阵,按照 Trabelsi C. 等人的“Deep Complex Networks”中的描述进行初始化。

参数:
  • in_features (int) – 输入层实数值的数量 (四元数 // 4)。

  • out_features (int) – 输出层实数值的数量 (四元数 // 4)。

  • kernel_size (int) – 卷积层的 Kernel_size (例如: (3,3))。

  • criterion (str) – (glorot, he) (默认 “glorot”)

返回类型:

初始化的复数矩阵。

speechbrain.nnet.complex_networks.c_ops.affect_init(real_weight, imag_weight, init_func, criterion)[source]

将给定的权重初始化函数应用于参数。

参数:
  • real_weight (torch.Parameters)

  • imag_weight (torch.Parameters)

  • init_func (function) – (unitary_init, complex_init)

  • criterion (str) – (glorot, he)

speechbrain.nnet.complex_networks.c_ops.affect_conv_init(real_weight, imag_weight, kernel_size, init_func, criterion)[source]

将给定的权重初始化函数应用于参数。这是专门为卷积层编写的。

参数:
  • real_weight (torch.Parameters)

  • imag_weight (torch.Parameters)

  • kernel_size (int)

  • init_func (function) – (unitary_init, complex_init)

  • criterion (str) – (glorot, he)

speechbrain.nnet.complex_networks.c_ops.multi_mean(input, axes, keepdim=False)[source]

input 的多个维度执行 torch.mean