INNER CODE UNIT · Python

pack_with_inverse

lucidrains/vector-quantize-pytorch · vector_quantize_pytorch/binary_mapper.py:33

def pack_with_inverse(t, pattern):
    packed, ps = pack([t], pattern)

    def inverse(out, inv_pattern = None):
        inv_pattern = default(inv_pattern, pattern)
        unpacked, = unpack(out, ps, inv_pattern)
        return unpacked

    return packed, inverse

# binary mapper

class BinaryMapper(Module):
    def __init__(
        self,
        bits = 1,
        kl_loss_threshold = NAT, # 1 bit
        deterministic_on_eval = False

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…