Skip to content

Instantly share code, notes, and snippets.

View cgadski's full-sized avatar

Christopher Gadzinski cgadski

  • University of Luxembourg
  • Luxembourg
View GitHub Profile
@cgadski
cgadski / gist:2cbdf30b9a3e5bf091f6ca92e61bb8d3
Created December 10, 2025 09:31
module implementation
# forward(x) -> y
# backward(dy, x) -> dx
class Sigmoid(dl.Module):
"""
Will take x, return an array with the same shape and values
1 / (1 + e^(-x))
"""
using LinearAlgebra
using Random: randperm
using Plots
random_coordinates(n, k) = BitVector(
sum(Matrix(I, n, n)[:, randperm(n)[1:k]], dims = 2)[:, 1]
)
function random_subspace(n, d)
return qr(reshape(randn(n * d), n, d)).Q[:, 1:d]
from typing import List
from pulp import *
def pack_sets(target: List[int], sets: List[List[int]]) -> List[int]:
inputs = [LpVariable(f"s{i}", lowBound=0, cat="Integer") for i in range(len(sets))]
outputs = [LpVariable(f"y{i}") for i in range(len(target))]
prob = LpProblem("p", LpMinimize)
for (i, s) in enumerate(target):
prob += outputs[i] == sum(s[i] * inputs[j] for (j, s) in enumerate(sets))
# %%
import numpy as np
from scipy.linalg import null_space
# %%
letters = 'abcdefg'
k = len(letters)
def from_word(code):
return np.array([letters[c] in code for c in range(k)])
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<button onClick={props.close}>click me to close</button>
)
}
export default function Parent(): JSX.Element {
// this doesn't work
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<button onClick={props.close}>click me to close</button>
)
}
export default function Parent(): JSX.Element {
// this doesn't work
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<button onClick={props.close}>click me to close</button>
)
}
export default function Parent(): JSX.Element {
// this doesn't work
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<button onClick={props.close}>click me to close</button>
)
}
export default function Parent(): JSX.Element {
// this works
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<button onClick={props.close}>click me to close</button>
)
}
export default function Parent(): JSX.Element {
// this works
import { useState } from 'react'
function Child(props: { close: () => void }): JSX.Element {
return (
<div> <div> <div>
<button onClick={props.close}>click me to close</button>
</div> </div> </div>
)
}