Skip to content

Instantly share code, notes, and snippets.

@cloneofsimo
cloneofsimo / polynomial-sphere-map.md
Last active September 28, 2024 09:35
Does there exists polynomial map of degree m sending the S^n to itself?

Variant of AM-GM for Minimization

When dealing with functions of the form $f(x) = x^a + \frac{1}{x^b}$, a variant of the AM-GM inequality can be used to find the minimum. Specifically, if you have:

$$ f(x) = c_1 \cdot x^a + c_2 \cdot \frac{1}{x^b} $$

The minimum occurs at:

@cloneofsimo
cloneofsimo / prompt.md
Created August 19, 2024 04:55
Proooooompt

Summarization:

As a professional summarizer, create a concise and comprehensive summary of the provided text, be it an article, post, conversation, or passage, while adhering to these guidelines:

Craft a summary that is detailed, thorough, in-depth, and complex, while maintaining clarity and conciseness.

Incorporate main ideas and essential information, eliminating extraneous language and focusing on critical aspects.

Rely strictly on the provided text, without including external information.
@cloneofsimo
cloneofsimo / plots.md
Created August 16, 2024 05:23
GPT-generated-Plots
def plot_lr_final_loss_batchsize(file_path):
    # Load the data
    data = pd.read_csv(file_path)
    
    # Extract columns that match 'val_loss/val_loss_'
    val_loss_columns = [col for col in data.columns if col.startswith('val_loss/val_loss_')]
    
    # Sort val_loss_columns by K (numeric value after 'val_loss/val_loss_') in increasing order
@cloneofsimo
cloneofsimo / hr.py
Created August 8, 2024 08:54
bucket
import os
import torch
import json
from PIL import Image
from torch.utils.data import Dataset
from diffusers.models import AutoencoderKL
from streaming import MDSWriter
import logging
import time
@cloneofsimo
cloneofsimo / pp.py
Created August 8, 2024 05:11
vae_preprocess
import os
import torch
import json
from PIL import Image
from torch.utils.data import Dataset, DataLoader
from diffusers.models import AutoencoderKL
from streaming import MDSWriter
import logging
import time
@cloneofsimo
cloneofsimo / identitcal_training_dynamics.py
Created August 7, 2024 09:07
Demonstrate ABC invariance
# Suppose you have neural network that
# x_l = a_l * W_l x_{l-1}, W_l_{i,j} ~ N(0, b_l^2), Learning rate of W_l := c_l,
# If you are using adam, you can
# a_l <- a_l * A , b_l <- b_l / A, c_l <- c_l / A
# and it will have exactly identical training dynamics as before.
# This is known as ABC (ABCD) redundancy. For more general case: https://arxiv.org/abs/2308.01814
# Let me show you what I mean:
import torch
@cloneofsimo
cloneofsimo / vibecheckgen.py
Created July 27, 2024 13:23
vibecheckgen.py
import requests
import json
import base64
from PIL import Image
from io import BytesIO
import os
import openai
from openai import OpenAI
import fal_client
@cloneofsimo
cloneofsimo / aurav02.py
Created July 24, 2024 14:06
AuraFlow v0.2, sampling that handles self-unconditioning CFG
#### Inference utils
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from diffusers.image_processor import VaeImageProcessor
from diffusers.models import AutoencoderKL
@cloneofsimo
cloneofsimo / radical_image_descriptions.json
Last active September 8, 2024 16:45
Set of wildly complex image descriptions & atomic factual statements.
[
{
"description": "a flamboyant octopus dressed in a tuxedo is hosting an undersea tea party on a coral reef, complete with tiny teacups and saucers made from seashells. Each of the octopus's eight arms is elegantly balancing a different teapot, pouring colorful and sparkly liquid into the cups. Surrounding the octopus are a variety of sea creatures dressed in formal wear: a well-dressed clownfish is toasting with a miniature glass, a sea turtle wears a monocle and is engaged in deep conversation with a stylishly-attired seahorse, and a group of jellyfish float nearby, their translucent bodies glowing softly in the ambient light. Coral formations around them resemble extravagant table decorations, draped in strands of pearls and glittering seaweed, while a vibrant school of fish swims by, seemingly mesmerized by the spectacle. The scene is filled with a sense of whimsy and elegance, illuminated by streams of sunlight filtering down from above, creating a magical underwater atmosphere.",
"