Giter Site home page Giter Site logo

Comments (13)

rahulxie avatar rahulxie commented on September 17, 2024 1

yes, it solved. Thank you!

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

That means your dataset element is PIL.Image rather than torch.Tensor, (99% because dataset transform is None rather than PILToTensor), which is unexpected.


Update: This seems to because of transform=None

dataset = self.get_dataset('train', transform=None)
_, targets = dataset_to_tensor(dataset)

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

Would you mind reviewing the PR #150 ?
I haven't checked if it works yet, but I believe that shall solve the issue.

from trojanzoo.

rahulxie avatar rahulxie commented on September 17, 2024

It works, but a new problem occur:
Traceback (most recent call last):
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/train.py", line 36, in
model._train(**trainer)
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanvision/models/imagemodel.py", line 560, in _train
return super()._train(epochs=epochs, optimizer=optimizer, lr_scheduler=lr_scheduler,
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanzoo/models.py", line 1015, in _train
return train(module=self._model, num_classes=self.num_classes,
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanzoo/utils/train.py", line 63, in train
best_validate_result = validate_fn(loader=loader_valid, get_data_fn=get_data_fn,
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanvision/models/imagemodel.py", line 481, in _validate
return super()._validate(**kwargs)
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanzoo/models.py", line 1056, in _validate
return validate(module=module, num_classes=num_classes, loader=loader,
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanzoo/utils/train.py", line 246, in validate
loss = float(loss_fn(_input, _label, _output=_output, **kwargs))
File "/home/itl/Documents/xrh/backdoor/trojanzoo/examples/../trojanzoo/models.py", line 660, in loss
return criterion(_output, _label)
File "/home/itl/anaconda3/envs/trojanzoo/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/itl/anaconda3/envs/trojanzoo/lib/python3.10/site-packages/torch/nn/modules/loss.py", line 1163, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "/home/itl/anaconda3/envs/trojanzoo/lib/python3.10/site-packages/torch/nn/functional.py", line 2996, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: expected scalar type Float but found Long

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

That doesn't seem to be an obvious issue. Let me debug actually.

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

Thanks for finding the bug! Does the previous PR solve your issue?

from trojanzoo.

rahulxie avatar rahulxie commented on September 17, 2024

But the loss is nan.
image

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

remove your previously saved loss_weights.npy and regenerate one. It's saved at your dataset folder

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

Does it work? @rahulxie

from trojanzoo.

rahulxie avatar rahulxie commented on September 17, 2024

Does it work? @rahulxie

yes, it works! Thanks!

from trojanzoo.

rahulxie avatar rahulxie commented on September 17, 2024

I want to konw what kinds of models used to train gtsrb dataset. Is resnet18_comp ok with the same config of cifar10 (i.e., the "Quick Start" of "Train a model" in README.md) ?

from trojanzoo.

ain-soph avatar ain-soph commented on September 17, 2024

Yes, I think I use resnet18_comp in IMC paper.

You may add my WeChat?

ain-soph-aur

from trojanzoo.

rahulxie avatar rahulxie commented on September 17, 2024

ain-soph-aur

okok, I have send friend request.

from trojanzoo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.