Skip to content

Instantly share code, notes, and snippets.

@yng87
yng87 / graphs_puzzle.rs
Last active June 27, 2023 04:34
Graphs puzzle
use petgraph::{algo::is_isomorphic, graph::NodeIndex, graph::UnGraph};
fn add_possible_edges<T: Clone>(g: UnGraph<T, ()>, num_nodes: usize) -> Vec<UnGraph<T, ()>> {
let mut res = Vec::new();
for i in 0..num_nodes - 1 {
for j in (i + 1)..num_nodes {
if !g.contains_edge(NodeIndex::new(i), NodeIndex::new(j)) {
let mut new_g = g.clone();
new_g.add_edge(NodeIndex::new(i), NodeIndex::new(j), ());
res.push(new_g)
@yng87
yng87 / model_collapse_gaussian_mixture.ipynb
Created June 27, 2023 02:54
model_collapse_gaussian_mixture.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yng87
yng87 / dowhy_example.ipynb
Created December 9, 2022 06:27
Example of DoWhy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yng87
yng87 / model.py
Last active November 4, 2022 01:52
DDIM by Jax/Haiku
# fork from https://github.com/daigo0927/jax-ddim
from typing import List, Optional, Sequence, Tuple, Union
import haiku as hk
import jax
import jax.numpy as jnp
def sinusoidal_embedding(x, min_freq: float = 1.0, max_freq: float = 1000.0, embedding_dims: int = 32):
frequencies = jnp.exp(jnp.linspace(jnp.log(min_freq), jnp.log(max_freq), embedding_dims // 2))
@yng87
yng87 / improving_tfrs_accuracy.ipynb
Created September 18, 2022 06:57
improving_tfrs_accuracy.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yng87
yng87 / launch.json
Created January 17, 2021 04:50
C++14 env for debug
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",