Skip to content

Instantly share code, notes, and snippets.

View AdityaKane2001's full-sized avatar
💻
Attending one token at a time.

Aditya Kane AdityaKane2001

💻
Attending one token at a time.
View GitHub Profile
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/tmp/ipykernel_17/2958370653.py in <module>
1 for DATASET in POSSIBLE_DATASETS:
2 for MODEL_ALIAS in POSSIBLE_MODEL_ALIASES:
----> 3 train_eval_test(MODEL_ALIAS, DATASET)
/tmp/ipykernel_17/1094019785.py in train_eval_test(MODEL_ALIAS, DATASET)
35 model.train()
36 for batch in train_dl:
from scipy.stats import norm as dist_model
import numpy as np
import torch
cfg = None # training config
device = None # training device object
seen_classes = list(range(5)) # list of seen classes
OOD_CLASS_NUMBER = -1
def fit(prob_pos_X):
def _get_random_dims(self, area, height, width, max_iter=10):
"""
Working logic:
1. Initialize values, start for loop and generate required random values.
2. If h_crop and w_crop (i.e. the generated values) are lesser than image dimensions,
then generate random x and y values.
3. Cache these x and y values if they are useful (BOTH MUST BE USEFUL)
4. If cached values exist, return them, else return bad values (atleast one of x and y will contain -1).
Run cases:
1. Cached values can be filled multiple times. Any time, they will be useful.
def _pca_jitter(self, image, target):
"""
Applies PCA jitter to images.
Args:
image: Batch of images to perform random rotation on.
target: Target tensor.
Returns:
Augmented example with batch of images and targets with same dimensions.
"""
def _mixup(self, image, label, alpha=0.2) -> Tuple:
"""
Function to apply mixup augmentation. To be applied after
one hot encoding and before batching.
Args:
entry1: Entry from first dataset. Should be one hot encoded and batched.
entry2: Entry from second dataset. Must be one hot encoded and batched.
Returns:
Tuple with same structure as the entries.
"""
def random_flip(self, image: tf.Tensor, target: tf.Tensor) -> tuple:
"""
Returns randomly flipped batch of images. Only horizontal flip
is available
Args:
image: Batch of images to perform random rotation on.
target: Target tensor.
Returns:
Augmented example with batch of images and targets with same dimensions.
"""
@AdityaKane2001
AdityaKane2001 / horizontal_flip.py
Created January 15, 2022 16:11
Training RegNets gists
def random_flip(self, image: tf.Tensor, target: tf.Tensor) -> tuple:
"""
Returns randomly flipped batch of images. Only horizontal flip
is available
Args:
image: Batch of images to perform random rotation on.
target: Target tensor.
Returns:
Augmented example with batch of images and targets with same dimensions.
"""
bazel test keras/layers/convolutional_test
# Make sure you run the following command from the root of your Keras fork
# Note: The version 2.8.0 can change with changes in Keras versions.
bazel build //keras/tools/pip_package:build_pip_package
~/keras_installation/keras/bazel-bin/keras/tools/pip_package/build_pip_package ~/keras_installation/keras_pkg
pip3 install - force-reinstall - user ~/keras_installation/keras_pkg/keras-2.8.0-py2.py3-none-any.whl
.
└── keras/
├── api/
│ ├── BUILD
│ └── api_init_files.bzl
├── ...
└── <submodule name>/
└── BUILD