Skip to content

Instantly share code, notes, and snippets.

Avatar
😇
Learning

Mayank Gulati MakGulati

😇
Learning
View GitHub Profile
View TensorBoardStrategy.py
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."""
View simple_producer.py
# simple_producer.py
import faust
import numpy as np
import json
from typing import Mapping
from numpy import ndarray
from json import JSONEncoder
@MakGulati
MakGulati / environment.yml
Last active May 26, 2021
environment.yml
View environment.yml
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
View ray_keras_function.py
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()
View ray_keras_class.py
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
View gym.env
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:
View torch_visualize.txt
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:
@MakGulati
MakGulati / regex_mac.txt
Last active Dec 27, 2019
regex find and delete
View regex_mac.txt
#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
@MakGulati
MakGulati / for_conda_environment.txt
Last active Jan 26, 2020
make virtual environment in jupyter notebook
View for_conda_environment.txt
#using for conda environment
pip install environment_kernels
pip install --user ipykernel
python -m ipykernel install --user --name=new_planet