zhhlee/InterFusion

config_or_cls error

kimbedeuro opened this issue · 10 comments

Hi,
I try to implement InterFusion code follow by readme file.
But when i run the code, some kind of error occurs below.

error

I have already install all library as below.
image

It seems that your ExpConfig is not a mltk.Config class or instance. Can you successfully run the original stack_train.py? Maybe you can compare the scripts to find if there is any mistake about ExpConfig in your implementation.

The trained model parameters are stored in folder 'results/stack_train/result_params/', while the testing statistics (including the F1 score) are stored in 'results/stack_predict/result.json'.

These parameters are used in the model script (InterFusion.py or InterFusion_SWaT.py). There are two hidden variables, z1 and z2 in our method. The dimension of z1 is related to the feature dimensions of x, usually a small value. The z2 variable is related to the window_length of x. The conversion between x and z2 uses a group of Conv1D and Deconv1D layers (with stride 1 or 2), thus the output_shape and z2_dim can be calculated according to window_length (e.g., 30-15-15-8 for window_length=30). In this way, the parameters are determined by your network structure designs for different datasets (e.g., how many layers to use, etc.).

Sorry, you have made a mistake. The output_shape is the output_shape for each deconv1D layers, while the conv1D layers have output shapes in inverse order. e.g, the window_length=30, stride=[2,1,2] for each conv1D layer. Then after the first layer, shape=30/2=15 (stride=2); after the second layer, shape=15(stride=1), .... For deconv1D, the shapes are in inverse order. At the beginning, shape=z2_dim=8; after the first deconv (stride=2), shape=15; after the second (stride=1), shape=15, after the third (stride=2), shape=30. So we have z2_dim=8, output_shape=[15, 15, 30].

So these parameters are determined by your design about conv/deconv layers, including the input window_length, number of layers and strides.

z_dim is really an empirical parameter, so it's hard to say how to calculate it. The proper value of z_dim varies across different datasets, but it is usually a small value (e.g., less than 10). It acts like the latent dimension in a standard VAE model (but note that, z_dim is the latent dimension for each timestamp, so it's usually smaller than the number of feature dimensions). You may search different z_dim values for different datasets to achieve best performance, or simply use the default z_dim=3.