Skip to content

Instantly share code, notes, and snippets.

View MakGulati's full-sized avatar
😇
Learning

Mayank Gulati MakGulati

😇
Learning
View GitHub Profile
@MakGulati
MakGulati / for_conda_environment.txt
Last active January 26, 2020 11:46
make virtual environment in jupyter notebook
#using for conda environment
pip install environment_kernels
pip install --user ipykernel
python -m ipykernel install --user --name=new_planet
@MakGulati
MakGulati / regex_mac.txt
Last active December 27, 2019 21:58
regex find and delete
#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 / torch_visualize.txt
Created December 28, 2019 02:17
visual model pytorch
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:
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:
@MakGulati
MakGulati / ray_keras_class.py
Created February 14, 2021 10:08
ray_class_prob
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
@MakGulati
MakGulati / ray_keras_function.py
Created February 17, 2021 19:58
with normal function
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()
@MakGulati
MakGulati / environment.yml
Last active May 26, 2021 15:25
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
# simple_producer.py
import faust
import numpy as np
import json
from typing import Mapping
from numpy import ndarray
from json import JSONEncoder
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."""