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
[tool.poetry] | |
name = "til-23-cv" | |
version = "0.1.0" | |
description = "" | |
authors = ["Author <[email protected]>"] | |
readme = "README.md" | |
packages = [{include = "til_23_cv"}] | |
[tool.poetry.dependencies] | |
python = "^3.9" |
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
"""Utilities to hash `torch.Tensor` and `nn.Module.state_dict()`.""" | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
from xxhash import xxh3_64_hexdigest as hexdigest | |
__all__ = ["hash_tensor", "hash_model"] | |
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
"""Slot Attention implementation in PyTorch based on official TensorFlow implementation. | |
Some modifications were made, namely: | |
- Can pass forward previous slots to the next time step. | |
- Dynamic number of slots between calls. | |
- Uses `F.scaled_dot_product_attention` for more performance. | |
""" | |
from typing import Tuple |
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
/** | |
* @file Generates a colorful animated SVG of equilateral triangles on an isogrid. Pure JS version. | |
* @author John-Henry Lim <[email protected]> | |
*/ | |
/** Very simple RNG used for randomizing the animated triangles. */ | |
const detRNG = (s) => () => ((2 ** 31 - 1) & (s = Math.imul(48271, s))) / 2 ** 31 | |
/** The seeded RNG function. */ | |
let rand = () => 0.5 |
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
/** | |
* @file Suffering with typescript and breaking the tslinter a few times. | |
* @author John-Henry Lim <[email protected]> | |
*/ | |
/** K2 are the keys for the inner config. */ | |
export type InnerConfig<K2 extends keyof any,V extends keyof any> = Partial<Record<K2,V>>|V; | |
/** K1 are the keys for the outer config, K2 are the keys for the inner config. */ | |
export type LayeredConfig<K1 extends keyof any,K2 extends keyof any,V extends keyof any> = Partial<Record<K1,InnerConfig<K2,V>>>; | |
/** K1 and K2 are reversed on purpose. This is to invert the config structure. */ | |
export type DefaultLayeredConfig<K1 extends keyof any,K2 extends keyof any,V> = Readonly<Record<K2,Record<K1,V>>>; |