| Operation | Input | Result | Notes |
|---|---|---|---|
| map | F[A] , A => B |
F[B] |
Functor |
| apply | F[A] , F[A => B] |
F[B] |
Applicative |
| (fa, fb, ...).mapN | (F[A], F[B], ...) , (A, B, ...) => C |
F[C] |
Applicative |
| (fa, fb, ...).tupled | (F[A], F[B], ...) |
F[(A, B, ...)] |
Applicative |
| flatMap | F[A] , A => F[B] |
F[B] |
Monad |
| traverse | F[A] , A => G[B] |
G[F[A]] |
Traversable; fa.traverse(f) == fa.map(f).sequence; "foreach with effects" |
| sequence | F[G[A]] |
G[F[A]] |
Same as fga.traverse(identity) |
| attempt | F[A] |
F[Either[E, A]] |
Given ApplicativeError[F, E] |
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
| # train_grpo.py | |
| # | |
| # See https://github.com/willccbb/verifiers for ongoing developments | |
| # | |
| """ | |
| citation: | |
| @misc{brown2025grpodemo, | |
| title={Granular Format Rewards for Eliciting Mathematical Reasoning Capabilities in Small Language Models}, | |
| author={Brown, William}, |
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 torch | |
| from torchvision import models | |
| modules=list(models.resnet18(weights='IMAGENET1K_V1').children())[:-1] | |
| model = nn.Sequential(*modules) | |
| x = torch.rand(size=[1, 3, 640, 480]) | |
| emb = model(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
| from streamlit.report_thread import get_report_ctx | |
| from streamlit.hashing import _CodeHasher | |
| from streamlit.server.server import Server | |
| from prometheus_client.registry import REGISTRY | |
| from prometheus_client import Counter | |
| class _SessionState: | |
| def __init__(self, session, hash_funcs): | |
| """Initialize SessionState instance.""" |
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 cv2, numpy as np, os | |
| #parameters | |
| working_dir = '/home/stephen/Desktop/keras_demo/' | |
| cap = cv2.VideoCapture(0) | |
| org, font, scale, color, thickness, linetype = (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (234,12,123), 2, cv2.LINE_AA | |
| #chromakey values | |
| h,s,v,h1,s1,v1 = 16,0,64,123,111,187 #green | |
| h,s,v,h1,s1,v1 = 0,74,53,68,181,157 #skin tone |
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
| #Evolution Strategies with Keras | |
| #Based off of: https://blog.openai.com/evolution-strategies/ | |
| #Implementation by: Nicholas Samoray | |
| #README | |
| #Meant to be run on a single machine | |
| #APPLY_BIAS is currently not working, keep to False | |
| #Solves Cartpole as-is in about 50 episodes | |
| #Solves BipedalWalker-v2 in about 1000 |
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 datetime import datetime, timedelta | |
| import networkx as nx | |
| from airflow import DAG | |
| from airflow.operators import BashOperator, SubDagOperator | |
| start_date = datetime(year=2017, month=6, day=13, hour=19, minute=0) | |
| schedule_interval = '0 * * * 1-5' | |
| default_args = { |
I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6
apt-get update && apt-get install gdb
Picking the right architecture = Picking the right battles + Managing trade-offs
- Clarify and agree on the scope of the system
- User cases (description of sequences of events that, taken together, lead to a system doing something useful)
- Who is going to use it?
- How are they going to use it?
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
| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(data)) | |
| data_size, vocab_size = len(data), len(chars) |
NewerOlder