MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / __init__

Method __init__

models/NHitsMS.py:404–459  ·  view source on GitHub ↗
(self,
                 configs, 
                 n_s=0,
                 n_x=0,
                 n_s_hidden=0,
                 n_x_hidden=0,
                 stack_types=('identity', 'identity', 'identity'),
                 n_blocks=(1, 1, 1),
                 n_layers=(2, 2, 2, 2, 2, 2, 2, 2, 2),
                 n_mlp_units=[[512, 512], [512, 512], [512, 512]],
                 n_pool_kernel_size=(1, 1, 1),
                 n_freq_downsample=(24, 12, 1),
                 pooling_mode='max',
                 interpolation_mode='linear',
                 dropout_prob_theta=0.,
                 activation='ReLU',
                 initialization='lecun_normal',
                 batch_normalization=False,
                 shared_weights=False)

Source from the content-addressed store, hash-verified

402 NHITS Model.
403 """
404 def __init__(self,
405 configs,
406 n_s=0,
407 n_x=0,
408 n_s_hidden=0,
409 n_x_hidden=0,
410 stack_types=('identity', 'identity', 'identity'),
411 n_blocks=(1, 1, 1),
412 n_layers=(2, 2, 2, 2, 2, 2, 2, 2, 2),
413 n_mlp_units=[[512, 512], [512, 512], [512, 512]],
414 n_pool_kernel_size=(1, 1, 1),
415 n_freq_downsample=(24, 12, 1),
416 pooling_mode='max',
417 interpolation_mode='linear',
418 dropout_prob_theta=0.,
419 activation='ReLU',
420 initialization='lecun_normal',
421 batch_normalization=False,
422 shared_weights=False):
423 super().__init__()
424
425 self.seq_len = configs.seq_len
426 self.label_len = configs.label_len
427 self.pred_len = configs.pred_len
428
429 # Multi-scale configs
430 self.scale_factor = configs.scale_factor
431 self.scales = configs.scales
432 self.mv = moving_avg()
433 self.upsample = nn.Upsample(scale_factor=self.scale_factor, mode='linear')
434
435 # Initialization
436 self.blocks = []
437 for scale in self.scales:
438 tmp_n_mlp_units = [[512//scale, 512//scale], [512//scale, 512//scale], [512//scale, 512//scale]]
439 blocks = self.create_stack(stack_types=stack_types,
440 n_blocks=n_blocks,
441 n_time_in=(self.seq_len+self.pred_len)//scale,
442 n_time_out=self.pred_len//scale,
443 n_x=n_x,
444 n_x_hidden=n_x_hidden,
445 n_s=n_s,
446 n_s_hidden=n_s_hidden,
447 n_layers=n_layers,
448 n_mlp_units=tmp_n_mlp_units,
449 n_pool_kernel_size=n_pool_kernel_size,
450 n_freq_downsample=n_freq_downsample,
451 pooling_mode=pooling_mode,
452 interpolation_mode=interpolation_mode,
453 batch_normalization=batch_normalization,
454 dropout_prob_theta=dropout_prob_theta,
455 activation=activation,
456 shared_weights=shared_weights,
457 initialization=initialization)
458 self.blocks.append(t.nn.ModuleList(blocks))
459 self.blocks = t.nn.ModuleList(self.blocks)
460
461 def create_stack(self, stack_types, n_blocks,

Callers 13

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

create_stackMethod · 0.95
moving_avgClass · 0.70

Tested by

no test coverage detected