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

Shredder.ipynb #8

Open
xiaoyangx0 opened this issue Jun 14, 2022 · 2 comments
Open

Shredder.ipynb #8

xiaoyangx0 opened this issue Jun 14, 2022 · 2 comments

Comments

@xiaoyangx0
Copy link

So sorry to bother you. I have some questions.
In Shredder.ipynb, the class SplitNN is not the subclass of nn.Module, and also does not define the attribute of train. So why there is a code of splitnn.train() in first line of nineteenth block, aslo the questions is the same as splitnn.zero_grads(),splitnn.backward().
The code and the reason of fault is as following.
THX
`splitnn.train()
for epoch in range(3):
epoch_loss = 0
epoch_outputs = []
epoch_labels = []
for i, data in enumerate(victim_train_dataloader):
splitnn.zero_grads()
inputs, labels = data
inputs = inputs.to(device)
labels = labels.to(device)

    outputs = splitnn(inputs)
    loss = criterion(outputs, labels)
    loss.backward()
    epoch_loss += loss.item() / len(victim_train_dataloader.dataset)
    
    epoch_outputs.append(outputs)
    epoch_labels.append(labels)
    
    splitnn.backward()
    splitnn.step()
    
print(epoch_loss, accuracy(torch.cat(epoch_labels),
                            torch.cat(epoch_outputs)))`

`---->Shredder.ipynb#ch0000013vscode-remote?line=0) splitnn.train()
Shredder.ipynb#ch0000013vscode-remote?line=1) for epoch in range(3):
Shredder.ipynb#ch0000013vscode-remote?line=2) epoch_loss = 0

AttributeError: 'SplitNN' object has no attribute 'train'`

@Koukyosyumei
Copy link
Owner

Koukyosyumei commented Jun 14, 2022

@xiaoyangx0

Thank you for your report! I found a bug in the build process of this package and fixed it. I guess re-installing will help your errors. I have also prepared the example notebook with google colab.

https://colab.research.google.com/drive/1C2UTAfReN94IxsX8ZEdN6odI9Ans9V4m?usp=sharing

@xiaoyangx0
Copy link
Author

@xiaoyangx0

Thank you for your report! I found a bug in the build process of this package and fixed it. I guess re-installing will help your errors. I have also prepared the example notebook with google colab.

https://colab.research.google.com/drive/1C2UTAfReN94IxsX8ZEdN6odI9Ans9V4m?usp=sharing

Thanks for your reply!
I have solved the problem by re-installing.
There are also some little bugs ,mainly focued on the problems that weights are in gpu but inputs are in cpu. But it is easy to solve.
Thanks for your reply and your code again!

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

2 participants