repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | casper4/rlp_decoder.se.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:38.529694 | macro calldatachar($x):
div(calldataload($x), 2**248)
macro calldatabytes_as_int($x, $b):
div(calldataload($x), 256**(32-$b))
def any():
# Positions of the values that we are changing
positions = array(256)
# Index of the next position we are adding to
positionIndex = 0
# Output data (main... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | casper4/sqrt.se.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:39.608176 | with inp = ~calldataload(0):
foo = inp
exp = 0
while foo >= 256:
foo = ~div(foo, 256)
exp += 1
with x = ~div(inp, 16 ** exp):
while 1:
y = ~div(x + ~div(inp, x) + 1, 2)
if x == y:
return x
x = y
|
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/arithmetization_builder.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:39.692380 | from utils import (
np, modinv, M31, log2, arange, array, zeros, append, m31_arith,
mk_junk_data
)
# We create our own mini-DSL that lets you specify a program as a series of
# opcodes. This then converts it into more efficient functions for filling
# the trace
# Here is a basic example of a program in that m... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | casper4/simulator.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:39.693022 | # Implements Minimal Slashing Conditions and dynamic validator sets, descriptions here:
# Slashing Conditions: https://docs.google.com/document/d/1ecFPYhe7YsKNQUAx48S8hoyK9Y4Rbe9be_lCe_vj2ek
# Dynamic Validator Sets: https://medium.com/@VitalikButerin/safety-under-dynamic-validator-sets-ef0c3bbdf9f6#.igylifcm9
import ... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | casper4/surround_checker.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:39.718850 | # NO_SURROUND validation checker. For any attestation, call `new_attestation(s, t)`.
# If there is a no surround validation, you will be notified. Requires 2*N*log(N)
# bits per validator in addition to the attestations themselves.
class CollisionFound(Exception):
pass
class Checker():
def __init__(self, MAX=... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fft.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.114094 | def log2(x):
assert x & (x-1) == 0
return x.bit_length() - 1
def point_add(pt1, pt2):
(x1, y1), (x2, y2) = pt1, pt2
return (
x1 * x2 - y1 * y2,
x1 * y2 + x2 * y1
)
def point_double(pt):
x1, y1 = pt
return (2 * x1 * x1 - 1, 2 * x1 * y1)
def point_multiply(pt, n):
if n =... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fields.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.151278 | class FieldElement():
def __init__(self, value):
if isinstance(value, self.__class__):
value = value.value
self.value = value % self.modulus
def __add__(self, other):
othervalue = other if isinstance(other, int) else other.value
return self.__class__((self.value + o... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fri.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.191328 | from fft import (
fft, inv_fft, get_initial_domain_of_size, log2,
halve_domain, get_single_domain_value, halve_single_domain_value
)
from merkle import merkelize, hash, get_branch, verify_branch
BASE_CASE_SIZE = 128
FOLDS_PER_ROUND = 3
FOLD_SIZE_RATIO = 2**FOLDS_PER_ROUND
NUM_CHALLENGES = 80
def extend_trace(... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fast_fft.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.221373 | from utils import (
cp, reverse_bit_order, log2
)
from zorch.m31 import (
M31, ExtendedM31, Point, modulus, zeros_like, Z, G
)
from precomputes import rbos, invx, invy, sub_domains
# Converts a list of evaluations to a list of coefficients. Note that the
# coefficients are in a "weird" basis: 1, y, x, xy, 2x^... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fast_stark.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.304055 | from utils import (
log2, get_challenges, merkelize_top_dimension,
rbo_index_to_original, pad_to,
eval_zpoly_at, projective_to_point,
fold, confirm_max_degree, cp
)
from zorch.m31 import (
M31, ExtendedM31, Point, modulus, zeros_like, Z, G
)
from precomputes import sub_domains
from fast_fft impor... |
ethereum/research | https://github.com/ethereum/research | null | null | null | null | 1,927 | null | null | mit | null | null | null | null | null | null | null | circlestark/fast_fri.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:40.334424 | from zorch.m31 import (
M31, ExtendedM31, Point, modulus, zeros_like, Z, G
)
from utils import (
log2, HALF, cp, reverse_bit_order,
merkelize_top_dimension, get_challenges, rbo_index_to_original
)
from precomputes import folded_rbos, invx, invy
from fast_fft import fft
from merkle import merkelize, hash, ge... |
NateScarlet/holiday-cn | https://github.com/NateScarlet/holiday-cn | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | scripts/update.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:42.402721 | #!/usr/bin/env python3
"""Script for updating data."""
import argparse
import json
import os
import re
import subprocess
from datetime import datetime, timedelta, tzinfo
from tempfile import mkstemp
from typing import Iterator
from zipfile import ZipFile
from tqdm import tqdm
from fetch import CustomJSONEncoder, fet... |
NateScarlet/holiday-cn | https://github.com/NateScarlet/holiday-cn | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | scripts/fetch_test.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:42.403316 | """Test module `fetch_holidays`."""
import json
import pytest
from fetch import (
CustomJSONEncoder,
DescriptionParser,
get_paper,
get_paper_urls,
get_rules,
)
from filetools import workspace_path
def test_get_paper_urls():
assert get_paper_urls(2019) == [
"http://www.gov.cn/zhengc... |
NateScarlet/holiday-cn | https://github.com/NateScarlet/holiday-cn | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | scripts/filetools.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:42.415685 | """Tools for files."""
import os
__dirname__ = os.path.abspath(os.path.dirname(__file__))
def workspace_path(*other):
return os.path.join(os.path.dirname(__dirname__), *other)
|
NateScarlet/holiday-cn | https://github.com/NateScarlet/holiday-cn | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | scripts/generate_ics.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:42.445450 | import datetime
from typing import Any, Iterator, Sequence, Text, Tuple
from icalendar import Event, Calendar, Timezone, TimezoneStandard
def _create_timezone():
tz = Timezone()
tz.add("TZID", "Asia/Shanghai")
tz_standard = TimezoneStandard()
tz_standard.add("DTSTART", datetime.datetime(1970, 1, 1))
... |
NateScarlet/holiday-cn | https://github.com/NateScarlet/holiday-cn | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | scripts/fetch.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:42.479810 | #!/usr/bin/env python3
"""Fetch holidays from gov.cn"""
import argparse
import json
import re
from datetime import date, timedelta
from itertools import chain
from typing import Iterator, List, Optional, Tuple
import bs4
import requests
PAPER_EXCLUDE = [
"http://www.gov.cn/zhengce/zhengceku/2014-09/29/content_91... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/knurling.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.640094 | from sdf import *
# main body
f = rounded_cylinder(1, 0.1, 5)
# knurling
x = box((1, 1, 4)).rotate(pi / 4)
x = x.circular_array(24, 1.6)
x = x.twist(0.75) | x.twist(-0.75)
f -= x.k(0.1)
# central hole
f -= cylinder(0.5).k(0.1)
# vent holes
c = cylinder(0.25).orient(X)
f -= c.translate(Z * -2.5).k(0.1)
f -= c.transl... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/mesh.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.641258 | from sdf import *
import sys
def hollowed_with_cross_hatch_ribs(f, shell_thickness, rib_width, rib_height, rib_spacing):
# make infinite cross-hatch rib pattern
d = rib_width / 2
rib = slab(z0=-d, z1=d).repeat(rib_spacing)
rib = rib.rotate(np.pi / 4, Y) | rib.rotate(-np.pi / 4, Y)
# intersect ribs... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/text.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.650602 | from sdf import *
FONT = 'Arial'
TEXT = 'Hello, world!'
w, h = measure_text(FONT, TEXT)
f = rounded_box((w + 1, h + 1, 0.2), 0.1)
f -= text(FONT, TEXT).extrude(1)
f.save('text.stl')
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/gearlike.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.652013 | from sdf import *
f = sphere(2) & slab(z0=-0.5, z1=0.5).k(0.1)
f -= cylinder(1).k(0.1)
f -= cylinder(0.25).circular_array(16, 2).k(0.1)
f.save('gearlike.stl', samples=2**26)
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/image.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.653126 | from sdf import *
IMAGE = 'examples/butterfly.png'
w, h = measure_image(IMAGE)
f = rounded_box((w * 1.1, h * 1.1, 0.1), 0.05)
f |= image(IMAGE).extrude(1) & slab(z0=0, z1=0.075)
f.save('image.stl')
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | docs/render.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.654759 | from sdf import *
import os
def generate(f, name, samples=2**26, **kwargs):
os.makedirs('models', exist_ok=True)
os.makedirs('images', exist_ok=True)
stl_path = 'models/%s.stl' % name
png_path = 'images/%s.png' % name
if os.path.exists(png_path):
return
render_cmd = './render %s %s' % (... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/pawn.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.660436 | from sdf import *
def section(z0, z1, d0, d1, e=ease.linear):
f = cylinder(d0/2).transition_linear(
cylinder(d1/2), Z * z0, Z * z1, e)
return f & slab(z0=z0, z1=z1)
f = section(0, 0.2, 1, 1.25)
f |= section(0.2, 0.3, 1.25, 1).k(0.05)
f |= rounded_cylinder(0.6, 0.1, 0.2).translate(Z * 0.4).k(0.05)
f |=... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/example.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.661432 | from sdf import *
f = sphere(1) & box(1.5)
c = cylinder(0.5)
f -= c.orient(X) | c.orient(Y) | c.orient(Z)
f.save('out.stl')
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/blobby.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.693178 | from sdf import *
s = sphere(0.75)
s = s.translate(Z * -3) | s.translate(Z * 3)
s = s.union(capsule(Z * -3, Z * 3, 0.5), k=1)
f = sphere(1.5).union(s.orient(X), s.orient(Y), s.orient(Z), k=1)
f.save('blobby.stl', samples=2**26)
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/customizable_box.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:44.721777 | from sdf import *
WIDTH = 12
HEIGHT = 6
DEPTH = 2
ROWS = 3
COLS = 5
WALL_THICKNESS = 0.25
WALL_RADIUS = 0.5
BOTTOM_RADIUS = 0.25
TOP_FILLET = 0.125
DIVIDER_THICKNESS = 0.2
ROW_DIVIDER_DEPTH = 1.75
COL_DIVIDER_DEPTH = 1.5
DIVIDER_FILLET = 0.1
LID_THICKNESS = 0.25
LID_DEPTH = 0.75
LID_RADIUS = 0.125
SAMPLES = 2 ** 24
d... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/d2.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.607716 | import functools
import numpy as np
import operator
from . import dn, d3, ease
# Constants
ORIGIN = np.array((0, 0))
X = np.array((1, 0))
Y = np.array((0, 1))
UP = Y
# SDF Class
_ops = {}
class SDF2:
def __init__(self, f):
self.f = f
def __call__(self, p):
return self.f(p).reshape((-1, 1... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/dn.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.616790 | import itertools
import numpy as np
_min = np.minimum
_max = np.maximum
def union(a, *bs, k=None):
def f(p):
d1 = a(p)
for b in bs:
d2 = b(p)
K = k or getattr(b, '_k', None)
if K is None:
d1 = _min(d1, d2)
else:
h = np... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/core.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.618361 | from functools import partial
from multiprocessing.pool import ThreadPool
from skimage import measure
import multiprocessing
import itertools
import numpy as np
import time
from . import progress, stl
WORKERS = multiprocessing.cpu_count()
SAMPLES = 2 ** 22
BATCH_SIZE = 32
def _marching_cubes(volume, level=0):
v... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.627355 | from . import d2, d3, ease
from .util import *
from .d2 import *
from .d3 import *
from .mesh import Mesh
from .text import (
measure_image,
measure_text,
image,
text,
)
from .core import (
generate,
save,
sample_slice,
show_slice,
)
from .stl import (
write_binary_stl,
)
|
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/ease.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.637767 | import numpy as np
def linear(t):
return t
def in_quad(t):
return t * t
def out_quad(t):
return -t * (t - 2)
def in_out_quad(t):
u = 2 * t - 1
a = 2 * t * t
b = -0.5 * (u * (u - 2) - 1)
return np.where(t < 0.5, a, b)
def in_cubic(t):
return t * t * t
def out_cubic(t):
u = t - 1... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | examples/weave.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.671916 | from sdf import *
f = rounded_box([3.2, 1, 0.25], 0.1).translate((1.5, 0, 0.0625))
f = f.bend_linear(X * 0.75, X * 2.25, Z * -0.1875, ease.in_out_quad)
f = f.circular_array(3, 0)
f = f.repeat((2.7, 5.4, 0), padding=1)
f |= f.translate((2.7 / 2, 2.7, 0))
f &= cylinder(10)
f |= (cylinder(12) - cylinder(10)) & slab(z0=... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/d3.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:45.701343 | import functools
import numpy as np
# import operator
from . import core, dn, d2, ease
# Constants
ORIGIN = np.array((0, 0, 0))
X = np.array((1, 0, 0))
Y = np.array((0, 1, 0))
Z = np.array((0, 0, 1))
UP = Z
# SDF Class
_ops = {}
class SDF3:
def __init__(self, f):
self.f = f
def __call__(self, p)... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/text.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:46.195756 | from PIL import Image, ImageFont, ImageDraw
import scipy.ndimage as nd
import numpy as np
from . import d2
# TODO: add support for newlines?
PIXELS = 2 ** 22
def _load_image(thing):
if isinstance(thing, str):
return Image.open(thing)
elif isinstance(thing, (np.ndarray, np.generic)):
return I... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | setup.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:46.224052 | from setuptools import setup
setup(
name='sdf',
version='0.1',
description='Generate 3D meshes from signed distance functions.',
author='Michael Fogleman',
author_email='michael.fogleman@gmail.com',
packages=['sdf'],
install_requires=[
'matplotlib',
'meshio',
'numpy'... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/progress.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:50.256319 | import sys
import time
def pretty_time(seconds):
seconds = int(round(seconds))
s = seconds % 60
m = (seconds // 60) % 60
h = (seconds // 3600)
return '%d:%02d:%02d' % (h, m, s)
class Bar(object):
def __init__(self, max_value=100, min_value=0, enabled=True):
self.min_value = min_value
... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/stl.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:50.352773 | import numpy as np
import struct
def write_binary_stl(path, points):
n = len(points) // 3
points = np.array(points, dtype='float32').reshape((-1, 3, 3))
normals = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])
normals /= np.linalg.norm(normals, axis=1).reshape((-1, 1))
dtype = np.... |
fogleman/sdf | https://github.com/fogleman/sdf | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | sdf/mesh.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:50.389255 | from scipy import interpolate
import numpy as np
import threading
from .d3 import sdf3, box
# TODO: allow transforming mesh
class Mesh:
@classmethod
def from_file(cls, path):
import meshio
mesh = meshio.read(path)
points = mesh.points
triangles = mesh.cells[0].data
... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 06_2_model_loss_and_ optimizer.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.480431 | # 1) Design model (input, output, forward pass with different layers)
# 2) Construct loss and optimizer
# 3) Training loop
# - Forward = compute prediction and loss
# - Backward = compute gradients
# - Update weights
import torch
import torch.nn as nn
# Linear regression
# f = w * x
# here : f = 2... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 03_autograd.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.489526 |
import torch
# The autograd package provides automatic differentiation
# for all operations on Tensors
# requires_grad = True -> tracks all operations on the tensor.
x = torch.randn(3, requires_grad=True)
y = x + 2
# y was created as a result of an operation, so it has a grad_fn attribute.
# grad_fn: references a ... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 06_1_loss_and_optimizer.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.506633 | # 1) Design model (input, output, forward pass with different layers)
# 2) Construct loss and optimizer
# 3) Training loop
# - Forward = compute prediction and loss
# - Backward = compute gradients
# - Update weights
import torch
import torch.nn as nn
# Linear regression
# f = w * x
# here : f = 2... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 05_1_gradientdescent_manually.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.522631 | import numpy as np
# Compute every step manually
# Linear regression
# f = w * x
# here : f = 2 * x
X = np.array([1, 2, 3, 4], dtype=np.float32)
Y = np.array([2, 4, 6, 8], dtype=np.float32)
w = 0.0
# model output
def forward(x):
return w * x
# loss = MSE
def loss(y, y_pred):
return ((y_pred - y)**2).mea... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 04_backpropagation.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.523877 | import torch
x = torch.tensor(1.0)
y = torch.tensor(2.0)
# This is the parameter we want to optimize -> requires_grad=True
w = torch.tensor(1.0, requires_grad=True)
# forward pass to compute loss
y_predicted = w * x
loss = (y_predicted - y)**2
print(loss)
# backward pass to compute gradient dLoss/dw
loss.backward()... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 02_tensor_basics.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.525318 | import torch
# Everything in pytorch is based on Tensor operations.
# A tensor can have different dimensions
# so it can be 1d, 2d, or even 3d and higher
# scalar, vector, matrix, tensor
# torch.empty(size): uninitiallized
x = torch.empty(1) # scalar
print(x)
x = torch.empty(3) # vector, 1D
print(x)
x = torch.empty(... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 08_logistic_regression.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.526998 | import torch
import torch.nn as nn
import numpy as np
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
# 0) Prepare data
bc = datasets.load_breast_cancer()
X, y = bc.data, bc.target
n_samples, n_features = X.shape
X_train, X_test, y_tr... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 09_dataloader.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.528310 | import torch
import torchvision
from torch.utils.data import Dataset, DataLoader
import numpy as np
import math
# gradient computation etc. not efficient for whole data set
# -> divide dataset into small batches
'''
# training loop
for epoch in range(num_epochs):
# loop over all batches
for i in range(total_b... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 05_2_gradientdescent_auto.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.529410 | import torch
# Here we replace the manually computed gradient with autograd
# Linear regression
# f = w * x
# here : f = 2 * x
X = torch.tensor([1, 2, 3, 4], dtype=torch.float32)
Y = torch.tensor([2, 4, 6, 8], dtype=torch.float32)
w = torch.tensor(0.0, dtype=torch.float32, requires_grad=True)
# model output
def f... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 07_linear_regression.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:52.556940 | import torch
import torch.nn as nn
import numpy as np
from sklearn import datasets
import matplotlib.pyplot as plt
# 0) Prepare data
X_numpy, y_numpy = datasets.make_regression(n_samples=100, n_features=1, noise=20, random_state=4)
# cast to float Tensor
X = torch.from_numpy(X_numpy.astype(np.float32))
y = torch.from... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 10_transformers.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.118933 | '''
Transforms can be applied to PIL images, tensors, ndarrays, or custom data
during creation of the DataSet
complete list of built-in transforms:
https://pytorch.org/docs/stable/torchvision/transforms.html
On Images
---------
CenterCrop, Grayscale, Pad, RandomAffine
RandomCrop, RandomHorizontalFlip, RandomRotation... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 11_softmax_and_crossentropy.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.127199 | import torch
import torch.nn as nn
import numpy as np
#
# -> 2.0 -> 0.65
# Linear -> 1.0 -> Softmax -> 0.25 -> CrossEntropy(y, y_hat)
# -> 0.1 -> 0.1
#
# scores(logits) probabilities
# sum = 1.0
#
# Softmax applies the... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 15_transfer_learning.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.150780 | import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import numpy as np
import torchvision
from torchvision import datasets, models, transforms
import matplotlib.pyplot as plt
import time
import os
import copy
mean = np.array([0.5, 0.5, 0.5])
std = np.array([... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 12_plot_activations.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.151909 | import numpy as np
import matplotlib.pyplot as plt
##### Sigmoid
sigmoid = lambda x: 1 / (1 + np.exp(-x))
x=np.linspace(-10,10,10)
y=np.linspace(-10,10,100)
fig = plt.figure()
plt.plot(y,sigmoid(y),'b', label='linspace(-10,10,100)')
plt.grid(linestyle='--')
plt.xlabel('X Axis')
plt.ylabel('Y Ax... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 12_activation_functions.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.153910 | # output = w*x + b
# output = activation_function(output)
import torch
import torch.nn as nn
import torch.nn.functional as F
x = torch.tensor([-1.0, 1.0, 2.0, 3.0])
# sofmax
output = torch.softmax(x, dim=0)
print(output)
sm = nn.Softmax(dim=0)
output = sm(x)
print(output)
# sigmoid
output = torch.sigmoid(x)
print(o... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 16_tensorboard.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.171134 | import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
############## TENSORBOARD ########################
import sys
import torch.nn.functional as F
from torch.utils.tensorboard import SummaryWriter
# default `log_dir` is "runs" - we'll be mor... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 13_feedforward.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.203392 | import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Hyper-parameters
input_size = 784 # 28x28
hidden_size = 500
num_classes = 10
num_epochs = 2... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 17_save_load.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.219414 | import torch
import torch.nn as nn
''' 3 DIFFERENT METHODS TO REMEMBER:
- torch.save(arg, PATH) # can be model, tensor, or dictionary
- torch.load(PATH)
- torch.load_state_dict(arg)
'''
''' 2 DIFFERENT WAYS OF SAVING
# 1) lazy way: save whole model
torch.save(model, PATH)
# model class must be defined somewhere
m... |
patrickloeber/pytorchTutorial | https://github.com/patrickloeber/pytorchTutorial | null | null | null | null | 1,925 | null | null | mit | null | null | null | null | null | null | null | 14_cnn.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:53.220041 | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
import numpy as np
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Hyper-parameters
num_epochs =... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/aliases.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.586719 | from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from django.contrib.admin.options import _FieldOpts as FieldOpts
from django.contrib.admin.options import _FieldsetSpec as FieldsetSpec
from django.db.models.query import _QuerySet
from django.utils.functional import _StrOrPromi... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/db/models/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.588913 | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import ClassVar
from django.db.models import BaseConstraint, Index
from django.db.models.expressions import Combinable
from django.utils.datastructures import _Li... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/annotations.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.590269 | from __future__ import annotations
from collections.abc import Mapping
from typing import Annotated, Any, Generic
from django.db.models.base import Model
from typing_extensions import TypeVar
# Really, we would like to use TypedDict as a bound, but it's not possible
_Annotations = TypeVar("_Annotations", covariant=T... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.591899 | from __future__ import annotations
from .aliases import FieldOpts as FieldOpts
from .aliases import FieldsetSpec as FieldsetSpec
from .aliases import QuerySetAny as QuerySetAny
from .aliases import StrOrPromise, StrPromise
from .aliases import ValuesQuerySet as ValuesQuerySet
from .annotations import Annotations as An... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/db/models/manager.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.594235 | from __future__ import annotations
from typing import TYPE_CHECKING
# Re-export stubs-only classes RelatedManger and ManyRelatedManager.
# These are fake, Django defines these inside function body.
if TYPE_CHECKING:
# noinspection PyUnresolvedReferences
from django.db.models.fields.related_descriptors import ... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/types.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.608122 | from __future__ import annotations
from typing import Any, Protocol
from typing_extensions import override
# Used internally by mypy_django_plugin.
class AnyAttrAllowed(Protocol):
def __getattr__(self, item: str) -> Any: ...
@override
def __setattr__(self, item: str, value: Any) -> None: ...
|
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/db/router.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.609091 | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
from django.db.models import Model
class TypedDatabaseRouter:
"""
Typed base class for Django's DATABASE_ROUTERS setting. At runtime this is just an alias to `object`.
Al... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.636742 | from __future__ import annotations
from typing import TYPE_CHECKING, Any, TypedDict, type_check_only
from typing_extensions import NotRequired
if TYPE_CHECKING:
from pathlib import Path
@type_check_only
class TemplatesSetting(TypedDict):
"""Typing helper if you want to type `TEMPLATE` setting."""
BACK... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/django_stubs_ext/patch.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:55.666050 | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Generic
from django import VERSION
from django.contrib.admin import ModelAdmin
from django.contrib.admin.options import BaseModelAdmin
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib.sessions.backends.db import... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/tests/test_aliases.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.171155 | from __future__ import annotations
from typing import Any
from django_stubs_ext import ValuesQuerySet
def test_extends_values_queryset() -> None:
class MyQS(ValuesQuerySet[Any, Any]):
pass
|
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | ext/tests/test_monkeypatching.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.194854 | from __future__ import annotations
from contextlib import suppress
from typing import TYPE_CHECKING, Protocol
import pytest
from django.db.models import Model
from django.forms.models import ModelForm
import django_stubs_ext
from django_stubs_ext import patch
from django_stubs_ext.patch import _need_generic, _Versio... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/django/context.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.212233 | from __future__ import annotations
import os
import sys
from collections import defaultdict
from contextlib import contextmanager
from functools import cached_property
from typing import TYPE_CHECKING, Any, Literal
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db import models
from djan... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/config.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.217918 | from __future__ import annotations
import configparser
import os
import sys
import textwrap
from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Any, NoReturn
if TYPE_CHECKING:
from collections.abc import Callable
if sys.version_info[:2] >= (3, 11):
import tomllib
else:
... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/errorcodes.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.228225 | from __future__ import annotations
from mypy.errorcodes import ErrorCode
MANAGER_MISSING = ErrorCode("django-manager-missing", "Couldn't resolve manager for model", "Django")
|
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/exceptions.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.279481 | from __future__ import annotations
class UnregisteredModelError(Exception):
"""The requested model is not registered"""
|
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/lib/fullnames.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.301896 | from __future__ import annotations
ABSTRACT_BASE_USER_MODEL_FULLNAME = "django.contrib.auth.base_user.AbstractBaseUser"
ABSTRACT_USER_MODEL_FULLNAME = "django.contrib.auth.models.AbstractUser"
PERMISSION_MIXIN_CLASS_FULLNAME = "django.contrib.auth.models.PermissionsMixin"
MODEL_METACLASS_FULLNAME = "django.db.models.b... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/lib/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.738010 | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypedDict, cast
from django.db.models.fields.related import RelatedField
from django.db.models.fields.reverse_related import ForeignObjectRel
from mypy import checker
from mypy.checker import TypeChecker
from mypy.checkmemb... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/main.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.784775 | from __future__ import annotations
import importlib.metadata
import itertools
import sys
from functools import cached_property, partial
from typing import TYPE_CHECKING, Any
from mypy.build import PRI_MED, PRI_MYPY
from mypy.modulefinder import mypy_path
from mypy.nodes import MypyFile, TypeInfo
from mypy.plugin impo... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/functional.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.825862 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.errorcodes import ATTR_DEFINED
from mypy.nodes import CallExpr, MemberExpr
from mypy.types import AnyType, Instance, TypeOfAny
from mypy.types import Type as MypyType
from mypy_django_plugin.lib import helpers
if TYPE_CHECKING:
from m... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/choices.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.827036 | from __future__ import annotations
from enum import Enum, auto
from typing import TYPE_CHECKING
from django.db.models.constants import LOOKUP_SEP
from mypy.nodes import MemberExpr, NameExpr, SuperExpr, TypeAlias, TypeInfo, Var
from mypy.typeanal import make_optional_type
from mypy.types import (
AnyType,
Inst... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/fields.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.832032 | from __future__ import annotations
from typing import TYPE_CHECKING, Any, NamedTuple, cast
from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields import AutoField, Field
from django.db.models.fields.related import RelatedField
from mypy.nodes import AssignmentStmt, NameExpr, TypeInfo
from m... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/forms.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.863421 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.nodes import TypeInfo
from mypy_django_plugin.lib import fullnames, helpers
if TYPE_CHECKING:
from mypy.plugin import ClassDefContext
def make_meta_nested_class_inherit_from_any(ctx: ClassDefContext) -> None:
meta_node = helpers... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/auth.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.868688 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.nodes import TypeInfo
from mypy.semanal import SemanticAnalyzer
from mypy.typeanal import TypeAnalyser
from mypy.types import PlaceholderType, ProperType
from mypy.types import Type as MypyType
from mypy.typevars import fill_typevars_with_a... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/init_create.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.882075 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.errorcodes import CALL_ARG
from mypy.types import Instance, get_proper_type
from mypy.types import Type as MypyType
from mypy_django_plugin.lib import helpers
if TYPE_CHECKING:
from django.db.models.base import Model
from mypy.plu... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/managers.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:56.883384 | from __future__ import annotations
from typing import TYPE_CHECKING, Final
from mypy.copytype import copy_type
from mypy.nodes import (
GDEF,
CallExpr,
Decorator,
FuncBase,
FuncDef,
MemberExpr,
Node,
OverloadedFuncDef,
PlaceholderNode,
RefExpr,
StrExpr,
SymbolTableNode,... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/manytomany.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.324305 | from __future__ import annotations
from typing import TYPE_CHECKING, NamedTuple
from mypy.nodes import AssignmentStmt, NameExpr, Node, TypeInfo
from mypy.types import Instance, ProperType, UninhabitedType, get_proper_type
from mypy.types import Type as MypyType
from mypy_django_plugin.lib import fullnames, helpers
... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/manytoone.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.399205 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.types import Instance, get_proper_type
from mypy.types import Type as MypyType
from mypy_django_plugin.lib import fullnames, helpers
if TYPE_CHECKING:
from mypy.plugin import MethodContext
def get_model_of_related_manager(ctx: Metho... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/orm_lookups.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.434257 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.nodes import ARG_NAMED, DictExpr, StrExpr
from mypy.types import AnyType, Instance, ProperType, TypeOfAny, get_proper_type
from mypy.types import Type as MypyType
from mypy_django_plugin.exceptions import UnregisteredModelError
from mypy_d... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/meta.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.440888 | from __future__ import annotations
from typing import TYPE_CHECKING
from django.core.exceptions import FieldDoesNotExist
from mypy.types import AnyType, Instance, TypeOfAny, get_proper_type
from mypy.types import Type as MypyType
from mypy_django_plugin.django.context import DjangoContext, get_field_type_from_model_... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/models.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.445181 | from __future__ import annotations
from collections import deque
from functools import cached_property
from typing import TYPE_CHECKING, Any, cast
from django.db.models.fields import DateField, DateTimeField, Field
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToManyRel, OneToOneRel
from m... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/request.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.450369 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.types import Type as MypyType
from mypy.types import UninhabitedType, get_proper_type
if TYPE_CHECKING:
from mypy.plugin import MethodContext
def check_querydict_is_mutable(ctx: MethodContext) -> MypyType:
ret_type = get_proper_t... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.465032 | from __future__ import annotations
from typing import TYPE_CHECKING
from mypy.nodes import MemberExpr
from mypy.types import AnyType, TypeOfAny
from mypy.types import Type as MypyType
from mypy_django_plugin.lib import helpers
if TYPE_CHECKING:
from mypy.plugin import AttributeContext
from mypy_django_plug... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | mypy_django_plugin/transformers/querysets.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.495281 | from __future__ import annotations
from typing import TYPE_CHECKING, Literal
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.fields.related import RelatedField
from django.db.models.fields.related_descriptors import (
Forward... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | scripts/django_tests_settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.511633 | # It is used in `mypy.ini` only.
# The following installed apps are required for stubtest to run correctly.
from __future__ import annotations
INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.admin",
"django.contrib.contenttypes",
"django.contrib.flatpages",
"django.contrib.redirects",
... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | scripts/tests_extension_hook.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:57.900466 | from __future__ import annotations
from typing import TYPE_CHECKING
from pytest_mypy_plugins.collect import File
if TYPE_CHECKING:
from pytest_mypy_plugins.item import YamlTestItem
def django_plugin_hook(test_item: YamlTestItem) -> None:
custom_settings = test_item.parsed_test_data.get("custom_settings", "... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/assert_type/conf/settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:58.383046 | from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from django_stubs_ext.settings import TemplatesSetting
BASE_DIR = Path(__file__).resolve().parent
# Example taken from various doc pages
# https://docs.djangoproject.com/en/stable/ref/settings/#templat... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/assert_type/apps/test_config.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:58.385377 | from __future__ import annotations
from django.apps.config import AppConfig
from django.utils.functional import cached_property
from typing_extensions import assert_type, override
class FooConfig(AppConfig):
name = "foo"
default_auto_field = "django.db.models.BigAutoField"
class BarConfig(AppConfig):
n... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/assert_type/contrib/admin/test_filters.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:58.385830 | from __future__ import annotations
from collections.abc import Iterator, Mapping
from typing import TYPE_CHECKING
from django.contrib.admin.filters import FieldListFilter, ListFilter, SimpleListFilter, _ListFilterChoices
from typing_extensions import assert_type, override
if TYPE_CHECKING:
from django.contrib.ad... |
typeddjango/django-stubs | https://github.com/typeddjango/django-stubs | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/assert_type/contrib/admin/test_decorators.py | null | null | null | null | null | null | Python | 2026-05-04T01:48:58.446428 | from __future__ import annotations
from typing import TYPE_CHECKING
from django.contrib import admin
from django.db import models
if TYPE_CHECKING:
from django.db.models import QuerySet
from django.http import FileResponse, HttpRequest, HttpResponse
class DisplayModel(models.Model):
@admin.display
... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_transformer.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.702053 | import torch
import torch.nn.functional as F
from torch import Tensor
from torch import nn
from bitnet.bit_ffn import BitFeedForward
from bitnet.bit_attention import BitMGQA
from zeta import OutputHead
def l2norm(t, dim=-1):
return F.normalize(t, dim=dim)
class RMSNorm(nn.Module):
"""
Root Mean Square ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_linear_new.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.703619 | from torch import nn, Tensor
from zeta.nn.modules.simple_rmsnorm import SimpleRMSNorm
import torch.nn.functional as F
def activation_quant(x: Tensor):
"""Per token quantization to 8bits. No grouping is needed for quantization
Args:
x (Tensor): _description_
Returns:
_type_: _description_... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_ffn.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.721403 | from typing import Callable, Optional
import torch
from torch import nn, Tensor
from bitnet.bitlinear import BitLinear
def default(val, d):
return val if val is not None else d
def init_zero_(tensor):
nn.init.constant_(tensor, 0.0)
# [GLU]
class GLU(nn.Module):
"""
Gated Linear Unit (GLU) module... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_lora.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.723112 | import torch
from torch import nn, Tensor
from bitnet.bitlinear import BitLinear
from zeta.nn.modules.simple_rmsnorm import SimpleRMSNorm
def weight_quant(w: Tensor):
scale = w.abs().mean()
e = w.mean()
u = (w - e).sign() * scale
return u
def activation_quant(x: Tensor):
"""Per token quantizatio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.