This file contains hidden or 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
--------------------------------------------------------------------------- | |
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: |
This file contains hidden or 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 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): |
This file contains hidden or 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
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. |
This file contains hidden or 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
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. | |
""" |
This file contains hidden or 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
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. | |
""" |
This file contains hidden or 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
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. | |
""" |
This file contains hidden or 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
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. | |
""" |
This file contains hidden or 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
bazel test keras/layers/convolutional_test |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
. | |
└── keras/ | |
├── api/ | |
│ ├── BUILD | |
│ └── api_init_files.bzl | |
├── ... | |
└── <submodule name>/ | |
└── BUILD |
NewerOlder