Coder Social home page Coder Social logo

about the datasetter.py about fedntd HOT 5 CLOSED

lee-gihun avatar lee-gihun commented on September 27, 2024
about the datasetter.py

from fedntd.

Comments (5)

Bhongcheng avatar Bhongcheng commented on September 27, 2024 1

It seems that in the mnist setting, the valid_transform should add "transforms.ToPILImage()"
image

Besides, it seems that I have understand my first question about "transform twice".........

from fedntd.

Bhongcheng avatar Bhongcheng commented on September 27, 2024

first...
def _build_truncated_dataset(self):
base_dataset = MNIST(
self.root, self.train, self.transform, None, self.download
)

second...
def getitem(self, index):
img, targets = self.data[index], self.targets[index]
if self.transform is not None:
img = self.transform(img)

  return img, targets

from fedntd.

Bhongcheng avatar Bhongcheng commented on September 27, 2024

When I set the dataset mint, it has error

Traceback (most recent call last):
File "/home/bhc/Desktop/back_up/FedLearn/main.py", line 155, in
main(opt)
File "/home/bhc/Desktop/back_up/FedLearn/main.py", line 100, in main
server.run()
File "/home/bhc/Desktop/back_up/FedLearn/algorithms/BaseServer.py", line 53, in run
test_acc = evaluate_model(
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/bhc/Desktop/back_up/FedLearn/algorithms/measures.py", line 18, in evaluate_model
for data, targets in dataloader:
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 681, in next
data = self._next_data()
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
return self._process_data(data)
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
data.reraise()
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/_utils.py", line 461, in reraise
raise exception
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/bhc/Desktop/back_up/FedLearn/train_tools/preprocessing/mnist/datasets.py", line 35, in getitem
img = self.transform(img)
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torchvision/transforms/transforms.py", line 94, in call
img = t(img)
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torchvision/transforms/transforms.py", line 134, in call
return F.to_tensor(pic)
File "/home/bhc/anaconda3/envs/bhc/lib/python3.9/site-packages/torchvision/transforms/functional.py", line 138, in to_tensor
raise TypeError(f"pic should be PIL Image or ndarray. Got {type(pic)}")
TypeError: pic should be PIL Image or ndarray. Got <class 'torch.Tensor'>

from fedntd.

zhanglong-web avatar zhanglong-web commented on September 27, 2024

为什么这个代码在运行时,会运行这么久呀,我把wandb那些都注释了,本地5轮,用的gpu跑还是好慢呀

from fedntd.

Lee-Gihun avatar Lee-Gihun commented on September 27, 2024

Sorry for the late reply. I missed testing on the MNIST setting after refactoring. Thank you for letting me know.

It seems that in the mnist setting, the valid_transform should add "transforms.ToPILImage()" image

Besides, it seems that I have understand my first question about "transform twice".........

When I translated, you're asking about the running time issue.

为什么这个代码在运行时,会运行这么久呀,我把wandb那些都注释了,本地5轮,用的gpu跑还是好慢呀

I guess the issue comes from CPU bottleneck, especially if the nvidia-smi command shows you low gpu utils. As I implemented by building dataloader for each client, data loading depends on the available cpu resource.

from fedntd.

Related Issues (4)

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.