Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem about the code implementation of ‘An Intrusion Detection System based on Deep Belief Networks’ #3

Open
Sandrw opened this issue Nov 11, 2022 · 18 comments
Assignees

Comments

@Sandrw
Copy link

Sandrw commented Nov 11, 2022

Hello, I feel deeply after reading your paper 'An Intrusion Detection System based on Deep Belief Networks'. I have to say, your ideas and abilities are great.But I have a question. Your paper mentioned that the "Infiltration" class was deleted when merging classes. According to Table 1: Class distribution of CICIDS2017 dataset, the merged dataset should only have 6 classes, There are also 6 classes in the deepBeliefNetwork.json file, but why do I implement the code when n_ Classes=6 will report an error, n_ Only when classes=7 can I run?I look forward to your reply. Thank you!

@Sandrw Sandrw closed this as completed Nov 11, 2022
@Sandrw Sandrw reopened this Nov 11, 2022
@othmbela othmbela self-assigned this Nov 11, 2022
@othmbela
Copy link
Owner

Hello @Sandrw,

Thank you for your comment.

I'm not sure I understand your question, but I'll try to give you some details on the implementation.

Indeed the Infiltration class was removed when merging the classes, and we ended up with 6classes. Therefore, I used 6nodes on the output layer (one node representing one class) for my DL models. Do you have any errors when running the code with n_classes=6? If so, could you please give some details on the error?

If you have more or fewer classes (for e.g. keeping the Infiltration class), you will need to specify the correct number of output nodes.

Please let me know if this could help.

@Sandrw
Copy link
Author

Sandrw commented Nov 11, 2022

Traceback (most recent call last):
  File "main.py", line 202, in <module>
    main(config)
  File "main.py", line 76, in main
    train_history = train(
  File "/root/autodl-tmp/DBN/utils/train.py", line 95, in train
    loss.backward()
  File "/root/miniconda3/lib/python3.8/site-packages/torch/_tensor.py", line 487, in backward
    torch.autograd.backward(
  File "/root/miniconda3/lib/python3.8/site-packages/torch/autograd/__init__.py", line 197, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
../aten/src/ATen/native/cuda/Loss.cu:242: nll_loss_forward_reduce_cuda_kernel_2d: block: [0,0,0], thread: [27,0,0] Assertion `t >= 0 && t < n_classes` failed.

@othmbela
Copy link
Owner

What is your environment? What are the parameters used?

Also, are you using Cuda to run the experiments? If so, could please confirm if you have the same issue when using the CPUs?

@Sandrw
Copy link
Author

Sandrw commented Nov 11, 2022

Yes, I used CUDA Version: 11.7. Because of the version correspondence problem, I used torch Version: 1.13.0. I think it will run faster on the GPUs than on the CPUs, so I didn't try it on the CPUs

@othmbela
Copy link
Owner

Could you please try it on the CPUs just to check if it's still throwing the error?

@Sandrw
Copy link
Author

Sandrw commented Nov 11, 2022

OK,I'll try it.Thank you for your reply!

@Sandrw
Copy link
Author

Sandrw commented Nov 12, 2022

Hello, I tried to run on CPUs, but the same problem occurred when I ran on GPUs for the first time. The error "IndexError: Target 6 is out of bounds."
The following is its error details

Traceback (most recent call last):
  File "main.py", line 203, in <module>
    main(config)
  File "main.py", line 77, in main
    train_history = train(
  File "/root/autodl-tmp/DBN/utils/train.py", line 94, in train
    loss = criterion(outputs, labels)
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1120, in forward
    return F.cross_entropy(input, target, weight=self.weight,
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/functional.py", line 2824, in cross_entropy
    return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
IndexError: Target 6 is out of bounds.

@Sandrw
Copy link
Author

Sandrw commented Nov 12, 2022

Hello, I searched the relevant information on the Internet, and the answer is basically two kinds, one is that the label doesn’t start from 0, the other is that n_ class and the number of nodes in the output layers are different. However, neither of them can solve the problem. In addition, I ran on the CPU again, and the result shows that it may not be a problem of the environment.

I would be grateful if you could give me some guidance. I will look forward to your reply!

@Sandrw
Copy link
Author

Sandrw commented Nov 15, 2022

Hello,@othmbela, I have tried other methods, but I still haven't solved this problem. If you have time, could you give me some guidance? I really sincerely look forward to your reply

@BlackRxing
Copy link

Hello, I searched the relevant information on the Internet, and the answer is basically two kinds, one is that the label doesn’t start from 0, the other is that n_ class and the number of nodes in the output layers are different. However, neither of them can solve the problem. In addition, I ran on the CPU again, and the result shows that it may not be a problem of the environment.

I would be grateful if you could give me some guidance. I will look forward to your reply!

i ran on cpu and encounter the same problem, do you mean when you run again, the result becomes normal? Have you found the solution my friend.

@Sandrw
Copy link
Author

Sandrw commented Dec 9, 2022 via email

@ssbagja
Copy link

ssbagja commented Dec 19, 2022

I remember that finally, I found some small problems with the dataset. After the modification, I put the code on the CPU, and the problem was solved inexplicably. However, I don't think it was caused by the problem with the dataset. I feel that the situation is very mysterious, so I'm sorry I didn't provide you with useful information 刘小志 @.***  

------------------ 原始邮件 ------------------ 发件人: "othmbela/dbn-based-nids" @.>; 发送时间: 2022年12月8日(星期四) 晚上9:29 @.>; @.@.>; 主题: Re: [othmbela/dbn-based-nids] A problem about the code implementation of ‘An Intrusion Detection System based on Deep Belief Networks’ (Issue #3) Hello, I searched the relevant information on the Internet, and the answer is basically two kinds, one is that the label doesn’t start from 0, the other is that n_ class and the number of nodes in the output layers are different. However, neither of them can solve the problem. In addition, I ran on the CPU again, and the result shows that it may not be a problem of the environment. I would be grateful if you could give me some guidance. I will look forward to your reply! i ran on cpu and encounter the same problem, do you mean when you run again, the result becomes normal? Have you found the solution my friend. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

i have the same problem, IndexError: Target 6 is out of bounds. can you help me how to fix the problem, thank you before

@superyuey
Copy link

Hello, I also encounter this problem while running the code. I think the reason is the unmatched code between data preprocessing and mainning process. Data preprocessing grouped labels into 7 classes inluding infiltration, but main process set a 6 labels list without infiltration class. The code ran successfully when I added infiltration class in main.py.

@han-x-z
Copy link

han-x-z commented Feb 22, 2023

Hello, I also encounter this problem while running the code. I think the reason is the unmatched code between data preprocessing and mainning process. Data preprocessing grouped labels into 7 classes inluding infiltration, but main process set a 6 labels list without infiltration class. The code ran successfully when I added infiltration class in main.py.

can you show me how you add infiltration clss in main.py your code screenshot

@limingjindev
Copy link

你好,我在运行代码的时候也遇到了这个问题。我认为原因是数据预处理和维护过程之间的代码不匹配。数据预处理将标签分为 7 个类别,包括渗透,但主过程设置了一个没有渗透类别的 6 个标签列表。当我在 main.py 中添加渗透类时,代码运行成功。
Can you send me an email with the modified code? [email protected]

@SUSHANTH009
Copy link

Screenshot 2024-02-18 at 12 48 00 PM even i am facing the same issue.please can someone help

@Sandrw
Copy link
Author

Sandrw commented Feb 18, 2024 via email

@Ftariq1992
Copy link

Hello, I also encounter this problem while running the code. I think the reason is the unmatched code between data preprocessing and mainning process. Data preprocessing grouped labels into 7 classes inluding infiltration, but main process set a 6 labels list without infiltration class. The code ran successfully when I added infiltration class in main.py.

can you pls send me procedure of this solution at [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants