Skip to content

Instantly share code, notes, and snippets.

View Interpause's full-sized avatar

John-Henry Lim Interpause

View GitHub Profile
@Interpause
Interpause / slot_attention.py
Last active April 1, 2023 06:35
PyTorch Slot Attention: Use efficient attention impl, dynamic number of slots, & can pass forward past slots.
"""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
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 17, 2024 09:23
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@jonathantneal
jonathantneal / README.md
Last active February 8, 2024 10:53
Nearest Normal Ratio Calculator

Nearest Normal Aspect Ratio

This function returns the nearest aspect ratio of a width and height within a limited range of possible aspect ratios.

In other words, while 649x360 technically has an aspect ratio of 649:360, it’s often useful to know that the nearest normal aspect ratio is actually 9:5 (648x360).

nearestNormalAspectRatio(width, height, [side], [maxWidth], [maxHeight])