zhhlee / InterFusion

KDD 2021: Multivariate Time Series Anomaly Detection and Interpretation using Hierarchical Inter-Metric and Temporal Embedding
MIT License
195 stars 46 forks source link

config_or_cls error #8

Closed kimbedeuro closed 2 years ago

kimbedeuro commented 2 years ago

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

zhhlee commented 2 years ago

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.

kimbedeuro commented 2 years ago

thank you for replying to me

I have one more question...

After running the algorithm, the results have four folders.

But I couldn't see the F1 score value... so where and how can I see the F1 score in this model?

Best regards,

Kim

================================================= Bedeuro Kim

Security Engineering Lab (27317). Department of Computer Science and Engineering, College of Information and Communication Engineering, Sungkyunkwan University (SKKU), 2066, Seobu-ro, Jangan, Suwon, Gyeonggi, Korea (440-746) https://seclab.skku.edu/people/bedeuro-kim/

Office : +82-31-299-4104 Mobile : +82-10-9981-6730 e-mail : @.***

-----Original Message----- From: @.> To: @.>; Cc: @.>; @.>; Sent: 2022-01-07 (금) 20:49:03 (GMT+09:00) Subject: Re: [zhhlee/InterFusion] config_or_cls error (Issue #8)

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. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

zhhlee commented 2 years ago

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'.

kimbedeuro commented 2 years ago

Hi,

I appreciate your comment on my question.

Now the code is working^^.

And I also have one question, when I do train the model I use the below command as you write in Github.

python algorithm/stack_train.py --dataset=SWaT --train.train_start=21600 --train.valid_portion=0.1 --model.window_length=30 '--model.output_shape=[15, 15, 30]' --model.z2_dim=8

In the command, output_shape is defined the [15,15,30] and z2_dim=8, How could you do setting this shape? Is there any specific method to define the output_shape and z2_dim? Because I try to run other datasets, I wonder how to do you set these parameters...

Best regards,

Kim

================================================= Bedeuro Kim

Security Engineering Lab (27317). Department of Computer Science and Engineering, College of Information and Communication Engineering, Sungkyunkwan University (SKKU), 2066, Seobu-ro, Jangan, Suwon, Gyeonggi, Korea (440-746) https://seclab.skku.edu/people/bedeuro-kim/

Office : +82-31-299-4104 Mobile : +82-10-9981-6730 e-mail : @.***

-----Original Message----- From: @.> To: @.>; Cc: @.>; @.>; Sent: 2022-01-19 (수) 02:11:59 (GMT+09:00) Subject: Re: [zhhlee/InterFusion] config_or_cls error (Issue #8)

Closed #8. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

zhhlee commented 2 years ago

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.).

kimbedeuro commented 2 years ago

Thank you for your answer^^

"the output_shape and z2_dim can be calculated according to window_length (e.g., 30-15-15-8 for window_length=30)"

So it means above your answer, For example, we use hidden variables and window length is "30" and we defined the output shape=[a,b,c]

a+b = window length c is the z_dim

Am I correctly understood?

So I can get various combinations of a and b? For example, the window length is 30 and z2_dim is 8, I can set the a and b like this?

[a,b,8]={[1,29,8],[2,28,8],[3,27,8],[4,26,8]....[29,1,8]}

Best regards, Kim

Bedeuro Kim

Security Engineering Lab (27317). Department of Computer Science and Engineering, College of Information and Communication Engineering, Sungkyunkwan University (SKKU), 2066, Seobu-ro, Jangan, Suwon, Gyeonggi, Korea (440-746) https://seclab.skku.edu/people/bedeuro-kim/

Office : +82-31-299-4104 Mobile : +82-10-9981-6730 e-mail : @.***

-----Original Message----- From: @.> To: @.>; Cc: @.>; @.>; Sent: 2022-01-28 (금) 15:46:44 (GMT+09:00) Subject: Re: [zhhlee/InterFusion] config_or_cls error (Issue #8)

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.). — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

zhhlee commented 2 years ago

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.

kimbedeuro commented 2 years ago

Thank you for your answer.

I understood the meaning of output_shape^^.

I have one more question, I think it is really the last question... Sorry for doing a lot of questions...

How could we calculate the z_dim? z_dim have different values according to the dataset. So if I change the code, I also change the z_dim...

Best regards, Kim

Bedeuro Kim

Security Engineering Lab (27317). Department of Computer Science and Engineering, College of Information and Communication Engineering, Sungkyunkwan University (SKKU), 2066, Seobu-ro, Jangan, Suwon, Gyeonggi, Korea (440-746) https://seclab.skku.edu/people/bedeuro-kim/

Office : +82-31-299-4104 Mobile : +82-10-9981-6730 e-mail : @.***

-----Original Message----- From: @.> To: @.>; Cc: @.>; @.>; Sent: 2022-01-28 (금) 17:10:40 (GMT+09:00) Subject: Re: [zhhlee/InterFusion] config_or_cls error (Issue #8)

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. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

zhhlee commented 2 years ago

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.

kimbedeuro commented 2 years ago

Thank you for your help~^^.

Best Regards, Kim 날짜: 2022.01.31 오후 06:37:09 (GMT+09:00) 제목: Re: [zhhlee/InterFusion] config_or_cls error (Issue #8)

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. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>