Skip to content

TypeError: 'tuple' object does not support item assignment #56

@ZhengtianZhu

Description

@ZhengtianZhu

Clients in Total: 5
--- Random Initialization ---
train_accuracy: 0.00500833, 10th percentile: 0, 50th percentile: 0.00304878, 90th percentile 0.0118636
train_loss: 4.13098, 10th percentile: 4.12663, 50th percentile: 4.13026, 90th percentile 4.13544
test_accuracy: 0.0148149, 10th percentile: 0, 50th percentile: 0, 90th percentile 0.0368978
test_loss: 4.12193, 10th percentile: 4.10857, 50th percentile: 4.12467, 90th percentile 4.13296
--- Round 1 of 2000: Training 3 Clients ---
Traceback (most recent call last):
File "main.py", line 186, in
main()
File "main.py", line 83, in main

sys_metrics = server.train_model(num_epochs=args.num_epochs, batch_size=args.batch_size, minibatch=args.minibatch)

File "/hy-tmp/leaf/models/server.py", line 60, in train_model
comp, num_samples, update = c.train(num_epochs, batch_size, minibatch)
File "/hy-tmp/leaf/models/client.py", line 39, in train
comp, update = self.model.train(data, num_epochs, num_data)
File "/hy-tmp/leaf/models/model.py", line 88, in train
self.run_epoch(data, batch_size)
File "/hy-tmp/leaf/models/model.py", line 96, in run_epoch
for batched_x, batched_y in batch_data(data, batch_size, seed=self.seed):
File "/hy-tmp/leaf/models/utils/model_utils.py", line 18, in batch_data
np.random.shuffle(data_x)
File "mtrand.pyx", line 4865, in mtrand.RandomState.shuffle
File "mtrand.pyx", line 4868, in mtrand.RandomState.shuffle
TypeError: 'tuple' object does not support item assignment

my conda list:
tmpEA3E

solutions:File "/hy-tmp/leaf/models/utils/model_utils.py", line 18, in batch_data
change np.random.shuffle(data_x) ->np.random.shuffle(list(data_x))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions