python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import logging
from dataclasses import dataclass
fro... | canife-main | FLSim/flsim/optimizers/async_aggregators.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import copy
from dataclasses import datac... | canife-main | FLSim/flsim/optimizers/optimizer_scheduler.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import logging
from dataclasses import da... | canife-main | FLSim/flsim/optimizers/sync_aggregators.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import random
from dataclasses import dataclass
from typing import List
import numpy as... | canife-main | FLSim/flsim/optimizers/tests/test_async_aggregator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
from flsim.common.pytest_helper import assertEqual, assertTrue
from flsim.... | canife-main | FLSim/flsim/optimizers/tests/test_optimizer_factories.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/optimizers/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
import pytest
from flsim.common.pytest_helper import assertEqual
from flsim... | canife-main | FLSim/flsim/optimizers/tests/test_lamb_optimizer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
from flsim.common.pytest_helper import assertAlmostEqual, assertEqual
from... | canife-main | FLSim/flsim/optimizers/tests/test_lars_optimizer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from flsim.common.pytest_helper import assertEqual, assertTrue
from flsim.o... | canife-main | FLSim/flsim/optimizers/tests/test_optimizer_scheduler.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Dict, Union
from flsim.optimizers.async_aggregators import (
... | canife-main | FLSim/flsim/optimizers/tests/test_optimizer_utils.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import logging
import math
from dataclasses import d... | canife-main | FLSim/flsim/trainers/async_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import logging
import math
import random
from datacl... | canife-main | FLSim/flsim/trainers/sync_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import copy
import math
import random
import sys
fro... | canife-main | FLSim/flsim/trainers/canary_sync_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore
from .async_trainer import AsyncTrainer... | canife-main | FLSim/flsim/trainers/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import logging
import sys
from dataclasse... | canife-main | FLSim/flsim/trainers/trainer_base.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from dataclasses import dataclass
from typing import... | canife-main | FLSim/flsim/trainers/private_sync_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Dict, List
import numpy as np
import pytest
import torch
from f... | canife-main | FLSim/flsim/trainers/tests/test_async_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/trainers/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import copy
from typing import Tuple
import numpy as np
import torch
from flsim.common.... | canife-main | FLSim/flsim/trainers/tests/test_async_trainer_weights.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import copy
import json
import math
from typing import List
import flsim.configs # noq... | canife-main | FLSim/flsim/trainers/tests/test_trainer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from enum import Enum
from typing import Union
import numpy as np
import torch
from fls... | canife-main | FLSim/flsim/trainers/tests/test_fedbuff.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import NamedTuple
EPS = 1e-10
class Timeline(NamedTuple):
"""
A... | canife-main | FLSim/flsim/common/timeline.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
from queue import PriorityQueue
from typing import Optional
from flsim.c... | canife-main | FLSim/flsim/common/training_simulator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""Utils class to fine tune a global model on client's train set then set the personaliz... | canife-main | FLSim/flsim/common/fine_tuner.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore # @manual
from .timeout_simulator impo... | canife-main | FLSim/flsim/common/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import List, Tuple
import numpy as np
from flsim.clients.async_c... | canife-main | FLSim/flsim/common/training_event_handler.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import sys
LOGGING_LEVEL: int = logging.INFO
# If this flag is true log... | canife-main | FLSim/flsim/common/logger.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
from enum import Enum
from typing import List, Tuple
class DiversityMetricType(Enum):
gradien... | canife-main | FLSim/flsim/common/diversity_metrics.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""Contains helpers for Python PyTest tests.
There is a list of helper utilities missin... | canife-main | FLSim/flsim/common/pytest_helper.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
from dataclasses import dataclass
from ty... | canife-main | FLSim/flsim/common/timeout_simulator.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import copy
import math
import random
from flsim.common.diversity_metrics import (
DiversityMetrics,
D... | canife-main | FLSim/flsim/common/tests/test_diversity_metrics.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from flsim.common.pytest_helper import (
assertAlmostEqual,
assertEqual,
ass... | canife-main | FLSim/flsim/common/tests/test_round_timeline.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/common/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from flsim.common.pytest_helper import (
assertAlmos... | canife-main | FLSim/flsim/common/tests/test_timeout_simulator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from flsim.clients.base_client import ClientConfig
from flsim.common.fine_t... | canife-main | FLSim/flsim/common/tests/test_fine_tuner.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import pytest
from flsim.clients.async_client import AsyncClien... | canife-main | FLSim/flsim/common/tests/test_training_event_handler.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import List, Tuple, Type
import numpy as np
import pytest
impor... | canife-main | FLSim/flsim/common/tests/test_training_simulator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# The base hydra configs for different components of FLSim are defined
# in their respec... | canife-main | FLSim/flsim/configs/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/configs/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import flsim.configs # noqa
from flsim.common.pytest_helper import assertRaises
from fl... | canife-main | FLSim/flsim/configs/tests/test_config_validation.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import copy
from dataclasses import dataclass
from t... | canife-main | FLSim/flsim/active_user_selectors/diverse_user_selector.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore # @manual
from .diverse_user_selector ... | canife-main | FLSim/flsim/active_user_selectors/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import copy
import math
from dataclasses ... | canife-main | FLSim/flsim/active_user_selectors/simple_user_selector.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/active_user_selectors/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
from collections import Counter
import torch
from flsim.active_user_selecto... | canife-main | FLSim/flsim/active_user_selectors/tests/test_active_user_selector.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
from collections import Counter
import torch
from flsim.active_user_selecto... | canife-main | FLSim/flsim/active_user_selectors/tests/test_diverse_user_selector.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore
from .data_sharder import (
Broadca... | canife-main | FLSim/flsim/data/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import random
from collections import def... | canife-main | FLSim/flsim/data/data_sharder.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Any, Dict
# see https://fb.workplace.com/groups/fbcode/pe... | canife-main | FLSim/flsim/data/csv_dataset.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from abc import ABC, abstractmethod
from typing impo... | canife-main | FLSim/flsim/data/data_provider.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Iterable, Optional, Type
import torch
from flsim.data.data_shar... | canife-main | FLSim/flsim/data/dataset_data_loader.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Dict
import pkg_resources
import pytest
import torch
from flsim... | canife-main | FLSim/flsim/data/tests/test_dataset_dataloader_with_batch.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/data/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
import random
import string
import torch
from flsim.common.pytest_helper im... | canife-main | FLSim/flsim/data/tests/test_data_sharder.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from enum import IntEnum
import torch
import torch.nn as nn
from flsim.utils.distribute... | canife-main | FLSim/flsim/servers/aggregator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from dataclasses import dataclass
from typing import... | canife-main | FLSim/flsim/servers/sync_dp_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore # @manual
from .sync_dp_servers import... | canife-main | FLSim/flsim/servers/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
from dataclasses import dataclass
from ty... | canife-main | FLSim/flsim/servers/sync_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from dataclasses import dataclass
from typing import... | canife-main | FLSim/flsim/servers/sync_secagg_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import List
import numpy as np
import pyt... | canife-main | FLSim/flsim/servers/tests/test_sync_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/servers/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from tempfile import mkstemp
import pytest
import torch.distributed as dist
import tor... | canife-main | FLSim/flsim/servers/tests/test_aggregator.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from flsim.channels.message import Message
from flsim.common.pytest_helper import assert... | canife-main | FLSim/flsim/servers/tests/test_sync_secagg_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import math
from tempfile import mkstemp
from unittest.mock import Magi... | canife-main | FLSim/flsim/servers/tests/test_sync_dp_servers.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from dataclasses import dataclass
from enum import I... | canife-main | FLSim/flsim/reducers/weighted_dp_round_reducer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore # @manual
from .base_round_reducer imp... | canife-main | FLSim/flsim/reducers/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""
This file defines the concept of a base round aggregator for a
federated learning se... | canife-main | FLSim/flsim/reducers/base_round_reducer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from dataclasses import dataclass
from itertools imp... | canife-main | FLSim/flsim/reducers/dp_round_reducer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
from dataclasses import dataclass
from tempfile import mkstemp
from typing i... | canife-main | FLSim/flsim/reducers/tests/test_round_reducer.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/reducers/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Any, Iterable
class IFLDataLoader(abc.ABC):
@abc.abs... | canife-main | FLSim/flsim/interfaces/data_loader.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/interfaces/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from enum import Enum, auto
from typing import Any, Dict, List, Optional, Tup... | canife-main | FLSim/flsim/interfaces/metrics_reporter.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Any
import torch.nn as nn
from flsim.interfaces.batch_met... | canife-main | FLSim/flsim/interfaces/model.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from dataclasses import dataclass
from omegaconf import MISSING
from torch.u... | canife-main | FLSim/flsim/interfaces/dataset.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Any, List
import torch
class IFLBatchMetrics(abc.ABC):
... | canife-main | FLSim/flsim/interfaces/batch_metrics.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from collections import OrderedDict
from dataclasses... | canife-main | FLSim/flsim/channels/scalar_quantization_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from collections import OrderedDict
from dataclasses... | canife-main | FLSim/flsim/channels/half_precision_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import math
from collections import OrderedDict
from... | canife-main | FLSim/flsim/channels/product_quantization_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from hydra.core.config_store import ConfigStore
from .base_channel import FLChannelConf... | canife-main | FLSim/flsim/channels/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from copy import deepcopy
from dataclasses import dataclass, field
from typing import Op... | canife-main | FLSim/flsim/channels/message.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
from dataclasses import dataclass
from ty... | canife-main | FLSim/flsim/channels/base_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from enum import Enum, auto
from flsim.utils.fl.stats import RandomVariableStatsTracker... | canife-main | FLSim/flsim/channels/communication_stats.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
from collections import OrderedDict
from dataclasses... | canife-main | FLSim/flsim/channels/sparse_mask_channel.py |
canife-main | FLSim/flsim/channels/pq_utils/__init__.py | |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
from sklearn.cluster import KMeans
class PQ:
"""
Qua... | canife-main | FLSim/flsim/channels/pq_utils/pq.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Type
import pytest
from flsim.channels.base_channel import FLChannel... | canife-main | FLSim/flsim/channels/tests/test_identity_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Type
import pytest
from flsim.channels.communication_stats import Ch... | canife-main | FLSim/flsim/channels/tests/test_scalar_quantization_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| canife-main | FLSim/flsim/channels/tests/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import Type
import pytest
from flsim.channels.communication_stats import Ch... | canife-main | FLSim/flsim/channels/tests/test_half_precision_channel.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import OrderedDict, Type
import pytest
import torch
from flsim.channels.bas... | canife-main | FLSim/flsim/channels/tests/test_sparse_mask_channel.py |
# Always prefer setuptools over distutils
import re
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# read the version from stanfordnlp/_version.py
version_file_contents = open(path.join(here, 'stanford... | stanfordnlp-master | setup.py |
from stanfordnlp.server import CoreNLPClient
# example text
print('---')
print('input text')
print('')
text = "Chris Manning is a nice person. Chris wrote a simple sentence. He also gives oranges to people."
print(text)
# set up the client
print('---')
print('starting up Java Stanford CoreNLP Server...')
# set up ... | stanfordnlp-master | demo/corenlp.py |
"""
basic demo script
"""
import sys
import argparse
import os
import stanfordnlp
from stanfordnlp.utils.resources import DEFAULT_MODEL_DIR
if __name__ == '__main__':
# get arguments
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--models_dir', help='location of models files | default: ~/... | stanfordnlp-master | demo/pipeline_demo.py |
# we want to just keep some shorter sentences here
import os
limit = 40
file_out = open('short40/en_ewt-ud-dev40.conllu', 'w')
linearr = []
write_line = True
os.system("touch short40/en_ewt-ud-dev40.conllu")
with open('en_ewt-ud-dev.conllu') as f:
for line in f:
linearr.append(line)
words = line.s... | stanfordnlp-master | UD_English-EWT/get_short_sents.py |
""" Single source of truth for version number """
__version__ = "0.1.3"
| stanfordnlp-master | stanfordnlp/_version.py |
from stanfordnlp.pipeline.core import Pipeline
from stanfordnlp.pipeline.doc import Document
from stanfordnlp.utils.resources import download
from stanfordnlp._version import __version__
| stanfordnlp-master | stanfordnlp/__init__.py |
"""
script for running full pipeline on command line
"""
import argparse
import os
from stanfordnlp import download, Pipeline
from stanfordnlp.pipeline.core import BOOLEAN_PROCESSOR_SETTINGS_LIST, PROCESSOR_SETTINGS_LIST
from stanfordnlp.utils.resources import default_treebanks, DEFAULT_MODEL_DIR
if __name__ == '__... | stanfordnlp-master | stanfordnlp/run_pipeline.py |
import io
from stanfordnlp.models.common import conll
from stanfordnlp.models.tokenize.data import DataLoader
from stanfordnlp.models.tokenize.trainer import Trainer
from stanfordnlp.models.tokenize.utils import output_predictions
from stanfordnlp.pipeline.processor import UDProcessor
from stanfordnlp.utils.postproces... | stanfordnlp-master | stanfordnlp/pipeline/tokenize_processor.py |
from stanfordnlp.models.common.pretrain import Pretrain
from stanfordnlp.models.pos.data import DataLoader
from stanfordnlp.models.pos.trainer import Trainer
from stanfordnlp.pipeline.processor import UDProcessor
class POSProcessor(UDProcessor):
def __init__(self, config, use_gpu):
# set up configuration... | stanfordnlp-master | stanfordnlp/pipeline/pos_processor.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.