Skip to content

Instantly share code, notes, and snippets.

View Banus's full-sized avatar
🌏
Building worlds

Emanuele Plebani Banus

🌏
Building worlds
View GitHub Profile
@Banus
Banus / kronecker_decompose.py
Created September 22, 2023 02:44 — forked from norabelrose/kronecker_decompose.py
Fast, optimal Kronecker decomposition
from einops import rearrange
from torch import Tensor
import torch
def kronecker_decompose(
A: Tensor, m: int, n: int, *, k: int = 1, niter: int = 10
) -> tuple[Tensor, Tensor]:
"""Frobenius-optimal decomposition of `A` into a sum of `k` Kronecker products.
# Mathieu Blondel, 2022
# BSD license
import numpy as np
from scipy.ndimage import convolve1d
from sklearn.metrics.pairwise import euclidean_distances
def smoothed_conjugate_conv(f, x, eps=1.0):
"""
@Banus
Banus / pytorch_seed.py
Last active December 22, 2021 22:18 — forked from righthandabacus/seed_everything.py
Random seeding
# Source: @kastnerkyle
# https://twitter.com/kastnerkyle/status/1473361479143460872
import os
import random
import numpy as np
import torch
default_seed=4142
print("Setting all possible default seeds based on {}".format(default_seed))
@Banus
Banus / README.md
Last active December 29, 2015 05:09 — forked from JoelBesada/README.md

Mendeley command for Backtick.

How to add this command:

  1. Copy the ID of your Gist from the URL. (7619625)

  2. Paste the ID into the custom commands field in the Backtick settings. You can easily access the settings by clicking the Backtick icon on the command execution console.