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
version: '3' | |
dotenv: ['.env'] | |
tasks: | |
setup: | |
desc: Setup development environment | |
cmds: | |
- poetry run pre-commit install | |
- poetry run pre-commit install --hook-type commit-msg |
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
""" | |
# Usage: | |
import argparse | |
from argparse_pathtype import PathType | |
parser = argparse.ArgumentParser(description='Process some integers.') | |
parser.add_argument('--dir-models', required=True, type=PathType(path_to="dir"), | |
help='Directory where models are stored') | |
""" |
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
# Docs to main working horse of those transformations: | |
# https://pytorch.org/docs/stable/nn.html?highlight=unfold#torch.nn.Unfold | |
# | |
def local_histogram( | |
batch: torch.Tensor, | |
*, | |
kernel_size: Union[int, tuple] = (3, 3), | |
stride: Union[int, tuple] = None, | |
bins: int = 10, | |
range_min: float = 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
def make_weights_for_balanced_classes(images, nclasses): | |
count = [0] * nclasses | |
for item in images: | |
count[item[1]] += 1 | |
weight_per_class = [0.] * nclasses | |
N = float(sum(count)) | |
for i in range(nclasses): | |
weight_per_class[i] = N/float(count[i]) | |
weight = [0] * len(images) | |
for idx, val in enumerate(images): |
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
def best_division(a): | |
""" | |
This function performs exhastive search over all possible divisions of array into 3 parts with equal sums | |
a - array on numbers (list<int|float>) | |
""" | |
results = [] | |
for i in range(1, len(a)-2+1): | |
for j in range(i+1, len(a)-1+1): | |
first, second, third = sum(a[:i]), sum(a[i:j]), sum(a[j:]) | |
opt_func = abs(first - second) + abs(second - third) + abs(first - third) |