Federated Computer Vision Module References

federatedscope.cv.dataset

class federatedscope.cv.dataset.leaf.LEAF(root, name, transform, target_transform)[source]

Base class for LEAF dataset from “LEAF: A Benchmark for Federated Settings”

Parameters
  • root (str) – root path.

  • name (str) – name of dataset, in LEAF_NAMES.

  • transform – transform for x.

  • target_transform – transform for y.

class federatedscope.cv.dataset.leaf.LocalDataset(Xs, targets, pre_process=None, transform=None, target_transform=None)[source]

Convert data list to torch Dataset to save memory usage.

class federatedscope.cv.dataset.leaf_cv.LEAF_CV(root, name, s_frac=0.3, tr_frac=0.8, val_frac=0.0, train_tasks_frac=1.0, seed=123, transform=None, target_transform=None)[source]

LEAF CV dataset from “LEAF: A Benchmark for Federated Settings”

leaf.cmu.edu

Parameters
  • root (str) – root path.

  • name (str) – name of dataset, ‘femnist’ or ‘celeba’.

  • s_frac (float) – fraction of the dataset to be used; default=0.3.

  • tr_frac (float) – train set proportion for each task; default=0.8.

  • val_frac (float) – valid set proportion for each task; default=0.0.

  • train_tasks_frac (float) – fraction of test tasks; default=1.0.

  • transform – transform for x.

  • target_transform – transform for y.

federatedscope.cv.dataloader

federatedscope.cv.dataloader.load_cv_dataset(config=None)[source]

Return the dataset of femnist or celeba.

Parameters

config – configurations for FL, see federatedscope.core.configs

Returns

FL dataset dict, with client_id as key.

Note

load_cv_dataset() will return a dict as shown below:

` {'client_id': {'train': dataset, 'test': dataset, 'val': dataset}} `

federatedscope.cv.model

class federatedscope.cv.model.ConvNet2(in_channels, h=32, w=32, hidden=2048, class_num=10, use_bn=True, dropout=0.0)[source]
forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class federatedscope.cv.model.ConvNet5(in_channels, h=32, w=32, hidden=2048, class_num=10, dropout=0.0)[source]
forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class federatedscope.cv.model.VGG11(in_channels, h=32, w=32, hidden=128, class_num=10, dropout=0.0)[source]
forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

federatedscope.cv.trainer

Copyright (c) 2021 Matthias Fey, Jiaxuan You <matthias.fey@tu-dortmund.de, jiaxuan@cs.stanford.edu>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.