Skip to content

Instantly share code, notes, and snippets.

View msakai's full-sized avatar

Masahiro Sakai msakai

View GitHub Profile
@msakai
msakai / Tomega.agda
Last active February 12, 2021 07:22
{-
https://twitter.com/andrejbauer/status/1358357606536986624
Today's exercise in constructive math: characterize the maximal
elements of Plotkin's domain T^ω := {(A,B) ∈ P(ℕ) × P(ℕ) | A ∩ B = ∅},
ordered by pairwise ⊆. Coq definitions are in the picture.
Hint: they are *not* just those that satisfy A ∪ B = ℕ.
-}
module Tomega where
{-# OPTIONS_GHC -Wall #-}
module OptimalTransport (computeOptimalTransport) where
import qualified Data.Vector.Generic as VG
import Numeric.LinearAlgebra ((<.>), (#>), (<#), (><))
import qualified Numeric.LinearAlgebra as LA
-- | Solve entropy regularized optimal transport problem:
--
-- \[
@msakai
msakai / ng.hs
Last active August 4, 2020 04:18
Interaction of ConstraintKinds and QuantifiedConstraints. There was already an issue about it https://gitlab.haskell.org/ghc/ghc/-/issues/16139 .
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
data Rose f a = Branch a (f (Rose f a))
type Eq1 f = (forall b. Eq b => Eq (f b))
{-
ng.hs:6:33: error:
• Expected a type, but ‘Eq (f b)’ has kind ‘Constraint’
• In the type ‘(forall b. Eq b => Eq (f b))’
@msakai
msakai / README.md
Last active August 1, 2020 15:08
Attempt to code "The Simple Essence of Automatic Differentiation" paper
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- translated from https://github.com/chokkan/liblbfgs
module LineSearch
( Params (..)
, defaultParams
, lineSearch
, lineSearchMoreThuente
) where
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)
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()}
import argparse
import numpy
import torch
from torch import nn
import torch.nn.functional as F
import ignite
import chainer
from chainer import training
#!/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