correct this: model = NBEATSx(h=1, inputsize=24, #loss=MQLoss(level=[80, 90]),…
- User
correct this: model = NBEATSx(h=1, input_size=24, #loss=MQLoss(level=[80, 90]), loss=DistributionLoss(distribution='Normal', level=[90]), #scaler_type='robust', stack_types=['identity'], dropout_prob_theta=0.1, hist_exog_list=['Var1','Var2','Var3','Var4','Var5','Var6','Var7','Var8','Var9','Var10','Var11','Var12','Var13', 'Var14','Var15','Var16', 'Var17','Var18','Var19','Var20','Var21','Var22','Var23','Var24' ], max_steps=200, val_check_steps=10, early_stop_patience_steps=2, mlp_units=list([10]))
TypeError Traceback (most recent call last) in <cell line: 15>() 13 Y_test_df['unique_id']=np.zeros(Y_test_df['ds'].shape) 14 ---> 15 model = NBEATSx(h=1, input_size=24, 16 #loss=MQLoss(level=[80, 90]), 17 loss=DistributionLoss(distribution='Normal', level=[90]),
2 frames /usr/local/lib/python3.10/dist-packages/neuralforecast/models/nbeatsx.py in init(self, input_size, h, futr_input_size, hist_input_size, stat_input_size, n_theta, mlp_units, basis, dropout_prob, activation) 207 208 hidden_layers = [ --> 209 nn.Linear(in_features=input_size, out_features=mlp_units[0][0]) 210 ] 211 for layer in mlp_units:
TypeError: 'int' object is not subscriptable
- Assistant
model = NBEATSx(h=1, input_size=24, #loss=MQLoss(level=[80, 90]), loss=DistributionLoss(distribution='Normal', level=[90]), #scaler_type='robust', stack_types=['identity'], dropout_prob_theta=0.1, hist_exog_list=['Var1','Var2','Var3','Var4','Var5','Var6','Var7','Var8','Var9','Var10','Var11','Var12','Var13', 'Var14','Var15','Var16', 'Var17','Var18','Var19','Var20','Var21','Var22','Var23','Var24' ], max_steps=200, val_check_steps=10, early_stop_patience_steps=2, mlp_units=[10])
- User
i tried and got this: INFO:lightning_fabric.utilities.seed:Seed set to 1
TypeError Traceback (most recent call last) in <cell line: 15>() 13 Y_test_df['unique_id']=np.zeros(Y_test_df['ds'].shape) 14 ---> 15 model = NBEATSx(h=1, input_size=24, 16 #loss=MQLoss(level=[80, 90]), 17 loss=DistributionLoss(distribution='Normal', level=[90]),
2 frames /usr/local/lib/python3.10/dist-packages/neuralforecast/models/nbeatsx.py in init(self, input_size, h, futr_input_size, hist_input_size, stat_input_size, n_theta, mlp_units, basis, dropout_prob, activation) 207 208 hidden_layers = [ --> 209 nn.Linear(in_features=input_size, out_features=mlp_units[0][0]) 210 ] 211 for layer in mlp_units:
TypeError: 'int' object is not subscriptable
- Assistant
It seems that the issue is with the specification of
mlp_unitsin theNBEATSxmodel. The errorTypeError: 'int' object is not subscriptableindicates that it is trying to use subscript notation[0]on an integer, which is not supported.To resolve this issue, you can modify the
mlp_unitsparameter to pass in just the integer value directly as follows:pythonmodel = NBEATSx(h=1, input_size=24, loss=DistributionLoss(distribution='Normal', level=[90]), stack_types=['identity'], dropout_prob_theta=0.1, hist_exog_list=['Var1','Var2','Var3','Var4','Var5','Var6','Var7','Var8','Var9','Var10','Var11','Var12','Var13', 'Var14','Var15','Var16', 'Var17','Var18','Var19','Var20','Var21','Var22','Var23','Var24' ], max_steps=200, val_check_steps=10, early_stop_patience_steps=2, mlp_units=10) - User
this is the correct way of defining mlp_units: List[List[int]], (Structure of hidden layers for each stack type. Each internal list should contain the number of units of each hidden layer.)
- Assistant
In that case, you should define the
mlp_unitsparameter as a list of lists, even if you have only one hidden layer. Here's how you can specify it correctly:pythonmodel = NBEATSx(h=1, input_size=24, loss=DistributionLoss(distribution='Normal', level=[90]), stack_types=['identity'], dropout_prob_theta=0.1, hist_exog_list=['Var1','Var2','Var3','Var4','Var5','Var6','Var7','Var8','Var9','Var10','Var11','Var12','Var13', 'Var14','Var15','Var16', 'Var17','Var18','Var19','Var20','Var21','Var22','Var23','Var24' ], max_steps=200, val_check_steps=10, early_stop_patience_steps=2, mlp_units=[[10]])By wrapping the integer
10in an inner list , you are providing the correct structure required for the parameter as a List[List[int]]. This should resolve the TypeError you encountered.