mindelec.architecture.MultiScaleFCCell
- class mindelec.architecture.MultiScaleFCCell(in_channel, out_channel, layers, neurons, residual=True, act='sin', weight_init='normal', has_bias=True, bias_init='default', num_scales=4, amp_factor=1.0, scale_factor=2.0, input_scale=None, input_center=None, latent_vector=None)[source]
The multi-scale network.
- Parameters
in_channel (int) – The number of channels in the input space.
out_channel (int) – The number of channels in the output space.
layers (int) – The total number of layers, include input/hidden/output layers.
neurons (int) – The number of neurons of hidden layers.
residual (bool) – full-connected of residual block for the hidden layers. Default: True.
act (Union[str, Cell, Primitive, None]) – activate function applied to the output of the fully connected layer, eg. ‘ReLU’.Default: “sin”.
weight_init (Union[Tensor, str, Initializer, numbers.Number]) – The trainable weight_init parameter. The dtype is same as input x. The values of str refer to the function initializer. Default: ‘normal’.
has_bias (bool) – Specifies whether the layer uses a bias vector. Default: True.
bias_init (Union[Tensor, str, Initializer, numbers.Number]) – The trainable bias_init parameter. The dtype is same as input x. The values of str refer to the function initializer. Default: ‘default’.
num_scales (int) – The subnet number of multi-scale network. Default: 4
amp_factor (Union[int, float]) – The amplification factor of input. Default: 1.0
scale_factor (Union[int, float]) – The base scale factor. Default: 2.0
input_scale (Union[list, None]) – The scale factor of input x/y/t. If not None, the inputs will be scaled before set in the network. Default: None.
input_center (Union[list, None]) – Center position of coordinate translation. If not None, the inputs will be translated before set in the network. Default: None.
latent_vector (Union[Parameter, None]) – Trainable parameter which will be concated with the sampling inputs and updated during training. Default: None.
- Inputs:
input (Tensor) - Tensor of shape \((*, in\_channels)\).
- Outputs:
Tensor of shape \((*, out\_channels)\).
- Raises
- Supported Platforms:
Ascend
Examples
>>> import numpy as np >>> from mindelec.architecture import MultiScaleFCCell >>> from mindspore import Tensor, Parameter >>> inputs = np.ones((64,3)) + 3.0 >>> inputs = Tensor(inputs.astype(np.float32)) >>> num_scenarios = 4 >>> latent_size = 16 >>> latent_init = np.ones((num_scenarios, latent_size)).astype(np.float32) >>> latent_vector = Parameter(Tensor(latent_init), requires_grad=True) >>> input_scale = [1.0, 2.0, 4.0] >>> input_center = [3.5, 3.5, 3.5] >>> net = MultiScaleFCCell(3, 3, 5, 32, ... weight_init="ones", bias_init="zeros", ... input_scale=input_scale, input_center=input_center, latent_vector=latent_vector) >>> output = net(inputs).asnumpy() >>> print(output.shape) (64, 3)