Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Yonemoto ityonemo

View GitHub Profile
@ityonemo
ityonemo / res_net_block.py
Last active Jan 20, 2021
Testing ResNet Components
View res_net_block.py
import torch
import torch.nn as nn
class ResNetBlock(nn.Module):
def __init__(self, input_channel_count, internal_channel_count, downsampler = None, stride=1, layers = 'all'):
# input_channel_count: An image tensor is a h*w*k tensor where k is represents
# how many channels, naively, groups of features discovered by the ml model.
# the shape of the input tensor is h*w*input_channel.
# internal_channel_count: like above, but the shape of the output tensor is
# h*w*internal_channel_count. In a typical convnet strategy, you will want the
@ityonemo
ityonemo / test.md
Last active Apr 5, 2021
Zig in 30 minutes
View test.md

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@ityonemo
ityonemo / algebra.zig
Last active Jan 4, 2021
Strategy for composable Algebra in Zig
View algebra.zig
const std = @import("std");
pub fn Algebra(comptime fields: []const type) type {
return struct{
pub fn @"<+>"(a: anytype, b: anytype) FieldFor(@TypeOf(a), @TypeOf(b)).Type {
const F: type = FieldFor(@TypeOf(a), @TypeOf(b));
return F.@"<+>"(a, b);
}
pub fn FieldFor(comptime AType: type, comptime BType: type) type {
@ityonemo
ityonemo / awaiting_resumed.zig
Created Dec 6, 2020
awaiting resumed ??? example
View awaiting_resumed.zig
const std = @import("std");
const print = std.debug.print;
var yielded = false;
fn yield() void {
yielded = true;
suspend;
}
@ityonemo
ityonemo / lisp.ex
Created Sep 20, 2020
Lisp in Elixir
View lisp.ex
defmodule Lisp do
@type ast :: [String.t | number | ast]
@type token :: :lp | :rp | number | String.t
@letters Enum.concat(?a..?z, ?A..?Z)
@numbers ?0..?9
@operators [?+]
@doc """
@ityonemo
ityonemo / gromacs.md
Last active Jul 30, 2020
gromacs installation on lambda v100
View gromacs.md

Gromacs on Lambda V100 nodes

Installation

  1. Install singularity
sudo apt-get update && sudo apt-get install -y build-essential libssl-dev uuid-dev \
  libgpgme11-dev squashfs-tools libseccomp-dev wget pkg-config git cryptsetup
View itinerary.jl
using JSON
#make sure we have what we're looking for.
(length(ARGS) == 0) && throw(ErrorException("needs a file name"))
###################################
#rows iterator
type rows; tgt::Matrix; end
Base.start(r::rows) = 1
Base.next(r::rows, idx) = (r.tgt[idx, :], idx + 1)
Base.done(r::rows, idx) = idx > size(r.tgt, 1)
@ityonemo
ityonemo / nbody-zig.zig
Last active Jun 17, 2020
benchmarks game: zig
View nbody-zig.zig
//! The Computer Language Benchmarks Game
//! https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
//!
//! This implementation is written in simple and idiomatic Zig.
//! The only optimization is using SIMD vector intrinsics.
const std = @import("std");
/////////////////////////////////////////////////////////////////////////
// important constants. ALLCAPS constants are not idiomatic Zig, but it's
View gist:00875891748bed3ee68e5f1b75c1ffe1
{
"Inspect": {
"prefix": "ins",
"body": "|> IO.inspect(label: \"$0$TM_LINE_NUMBER\")",
"description": "Adds a pipeline with a labelled `IO.inspect`",
}
}
View gist:4036b50fff8dcf373872440d3eee122b
#!/bin/sh
IMAGE=<your image id>
CMD=<your cmd>
podman run --net host -v $HOME:$HOME -e HOME="$HOME" -w$(PWD) -it $IMAGE "$CMD $@"