This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#using for conda environment | |
pip install environment_kernels | |
pip install --user ipykernel | |
python -m ipykernel install --user --name=new_planet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#find all files that are .png or .jpg and delete them | |
find . -type f \( -name "*.jpg" -o -name "*.png" \) -delete | |
#find all files that are not .png or .jpg and delete them | |
find . -type f ! \( -name "*.jpg" -o -name "*.png" \) -delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from graphviz import Digraph | |
import torch | |
from torch.autograd import Variable | |
def make_dot(var, params=None): | |
""" Produces Graphviz representation of PyTorch autograd graph | |
Blue nodes are the Variables that require grad, orange are Tensors | |
saved for backward in torch.autograd.Function | |
Args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Environment(object): | |
""" | |
The abstract environment class that is used by all agents. This class has the exact | |
same API that OpenAI Gym uses so that integrating with it is trivial. In contrast to the | |
OpenAI Gym implementation, this class only defines the abstract methods without any actual | |
implementation. | |
To implement your own environment, you need to define the following methods: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import tensorflow as tf | |
from tensorflow.keras.datasets import mnist | |
from ray.tune.integration.keras import TuneReportCallback | |
import ray | |
from ray import tune | |
from ray.tune.schedulers import AsyncHyperBandScheduler | |
from ray.tune import Trainable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from tensorflow.keras.datasets import mnist | |
from ray.tune.integration.keras import TuneReportCallback | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"--smoke-test", action="store_true", help="Finish quickly for testing") | |
args, _ = parser.parse_known_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: flwr | |
channels: | |
- defaults | |
dependencies: | |
- _libgcc_mutex=0.1=main | |
- _pytorch_select=0.1=cpu_0 | |
- _tflow_select=2.3.0=mkl | |
- absl-py=0.12.0=py38h06a4308_0 | |
- aiohttp=3.7.4=py38h27cfd23_1 | |
- astunparse=1.6.3=py_0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple_producer.py | |
import faust | |
import numpy as np | |
import json | |
from typing import Mapping | |
from numpy import ndarray | |
from json import JSONEncoder | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flwr as fl | |
import tensorflow as tf | |
from typing import Optional | |
from typing import List, Dict, Optional, Tuple | |
from flwr.common import Scalar | |
import os, os.path | |
def weighted_loss_avg(results: List[Tuple[int, float, Optional[float]]]) -> float: | |
"""Aggregate evaluation results obtained from multiple clients.""" |