Skip to content

Instantly share code, notes, and snippets.

Avatar

Masahiro Sakai msakai

View GitHub Profile
@msakai
msakai / README.md
Last active Aug 1, 2020
Attempt to code "The Simple Essence of Automatic Differentiation" paper
View pooling.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View LineSearch.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- translated from https://github.com/chokkan/liblbfgs
module LineSearch
( Params (..)
, defaultParams
, lineSearch
, lineSearchMoreThuente
) where
View concat_xlsx.rb
require 'win32ole'
ex = WIN32OLE.new("Excel.Application")
fso = WIN32OLE.new("Scripting.FileSystemObject")
files = ["Book1.xlsx", "Book2.xlsx"]
book = ex.Workbooks.Add
files.each { |file|
file = fso.GetAbsolutePathName(file)
View cython_pyro4_test.pyx
import Pyro4
import inspect
@Pyro4.expose
class C:
def m(self):
return 0
print(Pyro4.util.get_exposed_members(C()))
# => {'methods': set(), 'oneway': set(), 'attrs': set()}
View train_mnist_pytorch_evaluator_reporter.py
import argparse
import numpy
import torch
from torch import nn
import torch.nn.functional as F
import ignite
import chainer
from chainer import training
View train_mnist_chainermn_pytorch.py
#!/usr/bin/env python
import argparse
import torch
from torch import nn
import torch.nn.functional as F
import ignite
import chainer
from chainer import reporter
View train_mnist_pytorch.py
#!/usr/bin/env python
import argparse
import chainer
import chainer.functions as F
import chainer.links as L
from chainer import training
from chainer.training import extensions
import chainerx
View gadt.py
# Attempt to mimick following GADT (Generalized algebraic data type) in Python:
#
# data Expr a where
# Const :: a -> Expr a
# Add :: Expr Int -> Expr Int -> Expr Int
# Eq :: Expr Int -> Expr Int -> Expr Bool
# IfThenElse :: Expr Bool -> Expr a -> Expr a -> Expr a
import abc
from typing import Generic, TypeVar
View existential_type.py
# Encoding existential types in Python using ∃X. F(X) ≅ ∀R. (∀X. F(X) → R) → R.
import abc
from typing import Generic, TypeVar
S = TypeVar('S')
R = TypeVar('R')
class Automata(Generic[S], metaclass=abc.ABCMeta):