This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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)) | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| 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)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | |
| ) | |
| } |
NewerOlder