Skip to content

Instantly share code, notes, and snippets.

@DNGros
DNGros / winning_maps_out.txt
Created August 11, 2024 01:09
Dactile Maps Run (Aug 10)
ELECTION TODAY
Base frac dem: 0.5156333333333334
Winning maps:
Unique sets 255
states, P(D_wins_states), P(D_win_states ∩ D_win_nationally), P(D_win_states | D_win_nationally), P(D_win_nationally | D_win_states)
{MI}, 58.0%, 48.0%, 93.0%, 82.7%
{PA}, 53.2%, 47.4%, 91.8%, 89.0%
{WI}, 56.7%, 46.4%, 90.0%, 81.8%
{MI, PA}, 46.4%, 44.8%, 86.9%, 96.6%
{MI, WI}, 48.4%, 44.1%, 85.6%, 91.2%
@DNGros
DNGros / cubert_large_config.json
Created March 9, 2021 18:09
Quick CuBERT Huggingface Utils
{
"attention_probs_dropout_prob": 0.1,
"directionality": "bidi",
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 1024,
"initializer_range": 0.02,
"intermediate_size": 4096,
"max_position_embeddings": 512,
"num_attention_heads": 16,
@DNGros
DNGros / blobs_unique.py
Created February 21, 2021 09:34
CuBERT Manifest Dup Inspect
from pathlib import Path
from tqdm import tqdm
import pandas as pd
# Get the manifests from gs://cubert/20200621_Python/github_python_minus_ethpy150open_deduplicated_manifest
cubert_py_manifests_root = Path("REPLACE_WITH_PATH_WHERE_DOWNLOAD_MANIFESTS")
def get_manifest_df(num_files_limit: int = None) -> pd.DataFrame:
all_manifests = list(cubert_py_manifests_root.iterdir())
taken_manifests = all_manifests[:min(num_files_limit or 999999, len(all_manifests))]
@DNGros
DNGros / multiforward.py
Created January 4, 2019 07:38
Pytorch nn.Module with multiple forward methods
"""This code tries to address the desire to have different forwards with
different signatures and supporting static analysis / IDE hinting.
Example:
class MyModule(MultiforwardTorchModule):
@add_hooks
def forward_train(
hidden_state: torch.Tensor,
teacher_force_seq: List[str]
# training specific args...