Skip to content

Commit

Permalink
Fix args changes in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
IKACE committed Oct 5, 2022
1 parent 86b2510 commit 899377d
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 1,013 deletions.
10 changes: 5 additions & 5 deletions docs/Femnist_stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import matplotlib.pyplot as plt
import numpy as np

# Make sure you have downloaded and installed FedScale
import fedscale.core.config_parser as parser
from fedscale.dataloaders.femnist import FEMNIST
from fedscale.dataloaders.utils_data import get_data_transform
from fedscale.dataloaders.divide_data import DataPartitioner
from fedscale.core.config_parser import args
```


Expand All @@ -33,10 +33,10 @@ test_dataset = FEMNIST('./benchmark/dataset/data/femnist', dataset='test', trans
Partition the dataset by the `client_data_mapping` file, which gives the real-world client-level heterogeneity.

```{code-cell}
args.task = 'cv'
training_sets = DataPartitioner(data=train_dataset, args=args, numOfClass=62)
parser.args.task = 'cv'
training_sets = DataPartitioner(data=train_dataset, args=parser.args, numOfClass=62)
training_sets.partition_data_helper(num_clients=None, data_map_file='./benchmark/dataset/data/femnist/client_data_mapping/train.csv')
#testing_sets = DataPartitioner(data=test_dataset, args=args, numOfClass=62, isTest=True)
#testing_sets = DataPartitioner(data=test_dataset, args=parser.args, numOfClass=62, isTest=True)
#testing_sets.partition_data_helper(num_clients=None, data_map_file='./benchmark/dataset/data/femnist/client_data_mapping/train.csv')
```

Expand Down Expand Up @@ -76,7 +76,7 @@ rank=1
isTest = False
dropLast = True
partition = training_sets.use(rank - 1, isTest)
num_loaders = min(int(len(partition)/ args.batch_size/2), args.num_loaders)
num_loaders = min(int(len(partition)/ parser.args.batch_size/2), parser.args.num_loaders)
dataloader = DataLoader(partition, batch_size=16, shuffle=True, pin_memory=True, timeout=60, num_workers=num_loaders, drop_last=dropLast)
```

Expand Down
4 changes: 2 additions & 2 deletions examples/heterofl/customized_fllibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import torch.nn.functional as F
from resnet_heterofl import resnet18

from fedscale.core.config_parser import args
import fedscale.core.config_parser as parser


def init_model():
global tokenizer

logging.info("Initializing the model ...")
if args.model == 'resnet_heterofl':
if parser.args.model == 'resnet_heterofl':
model = resnet18()

return model
Expand Down
Loading

0 comments on commit 899377d

Please sign in to comment.