Skip to content

Instantly share code, notes, and snippets.

@45deg
45deg / tsp.py
Last active April 20, 2024 15:58
Traveling Salesman Problem (TSP) using the 2-opt algorithm (Japan's prefectoral capital) 都道府県庁所在地の巡回セールスマン
import random
import matplotlib.animation as animation
import matplotlib.pyplot as plt
capitals = {
'Hokkaido': (43.0646, 141.3468),
'Aomori': (40.8246, 140.7406),
'Iwate': (39.7036, 141.1527),
'Miyagi': (38.2688, 140.8721),
@45deg
45deg / gen.py
Last active March 20, 2024 13:17
Generating Spiral Dataset for Classifying in Python
import numpy as np
from numpy import pi
# import matplotlib.pyplot as plt
N = 400
theta = np.sqrt(np.random.rand(N))*2*pi # np.linspace(0,2*pi,100)
r_a = 2*theta + pi
data_a = np.array([np.cos(theta)*r_a, np.sin(theta)*r_a]).T
x_a = data_a + np.random.randn(N,2)

IQ1 AdC 16 日目

アカデミックライティングの訓練をしてこなかった人間(me)がさびしい英語力で何とか英語で論文を書いてきたときに使っていたサービスやツールを挙げていきます。

  • Hyper Collocation https://hypcol.marutank.net
    • 先に現れる/後に続く単語をarXivの論文の中から検索できるサービスです。
    • 前置詞や接続詞のどれが正しいか調べるのはもとより、この表現は widely accepted な表現かどうかを確かめるといった用途にも役立ちます (ちなみに今 "widely accepted" という表現が widely accepted かどうかを調べました)
    • 欠点としては、たまに(ノンネイティブの)間違った英語もarXivに乗っていることがあります。
  • Do people say? https://dopeoplesay.com
  • Reddit の書き込みから例文を検索するシステムです。
@45deg
45deg / delete_all_tweets.js
Created April 9, 2023 10:49
Farewell to Elon
const Twit = require('twit');
const fs = require('fs');
const { promisify } = require('util');
const ProgressBar = require('progress');
const asyncPool = require('tiny-async-pool');
const T = new Twit({
consumer_key: 'HERE',
consumer_secret: 'HERE',
access_token: 'HERE',
@45deg
45deg / tsp.gif
Last active April 4, 2023 20:01
2-opt tsp
tsp.gif
@45deg
45deg / Cargo.toml
Created March 23, 2023 18:15
Wordle for Rust by GPT-4
[package]
name = "wordle"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8"
@45deg
45deg / functional-music-programming.md
Last active January 31, 2023 01:49
関数型プログラミングでサウンドプログラミングをやるといった趣旨のPaper集 (2016)

From Sonic Pi to Overtone

Source: http://dl.acm.org/citation.cfm?doid=2505341.2505346

Sonic Pi (教育用のRasPi連携ができるプログラム) と Overtone (Lisp風のLive Coding言語) についてのレポート。1.1 の Related Research に関連分野がまとまっている。バックエンドとして用いているSuperColliderにも解説がある。


[Demo abstract] Scripthica: A Web Environment for Collective Algorithmic Composition

https://github.com/kohya-ss/sd-scripts/blob/main/train_network_README-ja.md これが正しい

  • 正則化画像はいらん
  • バッチサイズは2でいい
  • 巷の文章では学習用プロンプトの拡張子がtxtだが公式ではcaptionなので注意
  • dimは https://rentry.org/lora_train には 128 と書いてあるけど 4~16 ぐらいが無難 → dimの大きさによって重みを 1/n 倍する必要あり? → アップデートで直った
  • 最初は1epochでもうまく学習できてればそこそこ良い画像が生成される。うまく学習できてないといくら学習しても無が生成されることになる。
  • Additional Networks で 生成するときの weight は 0.1 付近じゃないとガビガビになる → アップデートで直った

@45deg
45deg / _raytracing_on_bigquery.png
Last active April 29, 2021 02:47
Ray Tracing on BigQuery (for free of charge)
_raytracing_on_bigquery.png
type prop =
True |
Var of char |
And of prop * prop |
Not of prop |
N of prop |
U of prop * prop
(* slow! *)
let eventually p = U (True, p)