docstr: Arguments:
  Ymat: input time-series n*T
  num_inputs: always set to 1
  num_channels: list containing channel progression of temporal comvolution network
  kernel_size: kernel size of temporal convolution filters
  dropout: dropout rate for each layer
  vbsize: vertical batch size
  hbsize: horizontal batch size
  lr: learning rate
  val_len: validation length
  test: always set to True
  end_index: no data is touched fro training or validation beyond end_index
  normalize: normalize dataset before training or not
  start_data: start data in YYYY-MM-DD format (give a random date if unknown)
  freq: "H" hourly, "D": daily and for rest see here:
      https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
      # timeseries-offset-aliases
  covariates: global covariates common for all time series r*T,
  where r is the number of covariates
  Ycov: per time-series covariates n*l*T, l such covariates per time-series
  use_time: if false, default trime-covriates are not used
  dti: date time object can be explicitly supplied here, leave None if default options are
      to be used
docstr_tok: ["Arguments",":","Ymat",":","input","time-series","n","*","T","num_inputs",":","always","set","to","1","num_channels",":","list","containing","channel","progression","of","temporal","comvolution","network","kernel_size",":","kernel","size","of","temporal","convolution","filters","dropout",":","dropout","rate","for","each","layer","vbsize",":","vertical","batch","size","hbsize",":","horizontal","batch","size","lr",":","learning","rate","val_len",":","validation","length","test",":","always","set","to","True","end_index",":","no","data","is","touched","fro","training","or","validation","beyond","end_index","normalize",":","normalize","dataset","before","training","or","not","start_data",":","start","data","in","YYYY-MM-DD","format","(","give","a","random","date","if","unknown",")","freq",":","``","H","''","hourly",",","``","D","''",":","daily","and","for","rest","see","here",":","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","timeseries-offset-aliases","covariates",":","global","covariates","common","for","all","time","series","r","*","T",",","where","r","is","the","number","of","covariates","Ycov",":","per","time-series","covariates","n","*","l","*","T",",","l","such","covariates","per","time-series","use_time",":","if","false",",","default","trime-covriates","are","not","used","dti",":","date","time","object","can","be","explicitly","supplied","here",",","leave","None","if","default","options","are","to","be","used"]
code: def __init__(
      self,
      Ymat,
      num_inputs=1,
      num_channels=[32, 32, 32, 32, 32, 1],
      kernel_size=7,
      dropout=0.2,
      vbsize=300,
      hbsize=128,
      lr=0.0005,
      val_len=10,
      test=True,
      end_index=120,
      normalize=False,
      start_date="2016-1-1",
      freq="H",
      covariates=None,
      use_time=False,
      dti=None,
      Ycov=None,
  ):
      """
      Arguments:
      Ymat: input time-series n*T
      num_inputs: always set to 1
      num_channels: list containing channel progression of temporal comvolution network
      kernel_size: kernel size of temporal convolution filters
      dropout: dropout rate for each layer
      vbsize: vertical batch size
      hbsize: horizontal batch size
      lr: learning rate
      val_len: validation length
      test: always set to True
      end_index: no data is touched fro training or validation beyond end_index
      normalize: normalize dataset before training or not
      start_data: start data in YYYY-MM-DD format (give a random date if unknown)
      freq: "H" hourly, "D": daily and for rest see here:
          https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
          # timeseries-offset-aliases
      covariates: global covariates common for all time series r*T,
      where r is the number of covariates
      Ycov: per time-series covariates n*l*T, l such covariates per time-series
      use_time: if false, default trime-covriates are not used
      dti: date time object can be explicitly supplied here, leave None if default options are
          to be used
      """
      self.start_date = start_date
      if use_time:
          self.time = TimeCovariates(
              start_date=start_date,
              freq=freq,
              normalized=True,
              num_ts=Ymat.shape[1],
          )
          if dti is not None:
              self.time.dti = dti
          time_covariates = self.time.get_covariates()
          if covariates is None:
              self.covariates = time_covariates
          else:
              self.covariates = np.vstack([time_covariates, covariates])
      else:
          self.covariates = covariates
      self.Ycov = Ycov
      self.freq = freq
      self.vbsize = vbsize
      self.hbsize = hbsize
      self.num_inputs = num_inputs
      self.num_channels = num_channels
      self.lr = lr
      self.val_len = val_len
      self.Ymat = Ymat
      self.end_index = end_index
      self.normalize = normalize
      self.kernel_size = kernel_size
      self.dropout = dropout
      if normalize:
          Y = Ymat
          m = np.mean(Y[:, 0 : self.end_index], axis=1)
          s = np.std(Y[:, 0 : self.end_index], axis=1)
          # s[s == 0] = 1.0
          s += 1.0
          Y = (Y - m[:, None]) / s[:, None]
          mini = np.abs(np.min(Y))
          self.Ymat = Y + mini
  
          self.m = m
          self.s = s
          self.mini = mini
  
      if self.Ycov is not None:
          self.num_inputs += self.Ycov.shape[1]
      if self.covariates is not None:
          self.num_inputs += self.covariates.shape[0]
  
      self.seq = TemporalConvNet(
          num_inputs=self.num_inputs,
          num_channels=num_channels,
          kernel_size=kernel_size,
          dropout=dropout,
          init=True,
      )
  
      self.seq = self.seq.float()
  
      self.D = TCMFDataLoader(
          Ymat=self.Ymat,
          vbsize=vbsize,
          hbsize=hbsize,
          end_index=end_index,
          val_len=val_len,
          covariates=self.covariates,
          Ycov=self.Ycov,
      )
      self.val_len = val_len
  
imports: import pickle
  import numpy
  import torch
  import torch.nn
  import torch.optim
  from torch.autograd import Variable
  from torch.nn.utils import weight_norm
  from bigdl.chronos.model.tcmf.data_loader import TCMFDataLoader
  from bigdl.chronos.model.tcmf.time import TimeCovariates
  import logging
label_desc: Use image node_id 1 to create a new LocalModel object from inherited base classes: object with example: obj = LocalModel(Ymat, num_inputs, num_channels, kernel_size, dropout, vbsize, hbsize, lr, val_len, test, end_index, normalize, start_date, freq, covariates, use_time, dti, Ycov)