This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************** | |
Problem: 1146 | |
User: YangZX | |
Language: C++ | |
Result: Accepted | |
Time:7192 ms | |
Memory:162696 kb | |
****************************************************************/ | |
int getint(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 执行同等大小的矩阵乘法10次的总时间(gcc version 4.8.1, 64位linux),第一项是取块大小为50的分块乘法,第二项是朴素乘法 | |
* | |
* 无任何优化选项 | |
* 500*500 8.05s 8.52s | |
* 1000*1000 64.96s 111.66s | |
* | |
* 开启O2 | |
* 500*500 1.78s 1.89s | |
* 1000*1000 14.46s 88.94s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* yangzx's red-black tree! */ | |
#include <cstdio> | |
#include <algorithm> | |
#include <cstdlib> | |
using namespace std; | |
struct RBTree{ | |
struct RBNode{ | |
int val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kernel = 2; | |
switch kernel | |
case 1; k = @(x, y) 1 * (x'*y + 1); | |
case 2; k = @(x, y) exp(-1 * (x-y)' * (x-y)); | |
case 3; k = @(x, y) 1 * (x'*y + 1) * (x'*y + 1) + x'*y+1 | |
case 4; k = @(x, y) 1 * min(x, y) | |
end | |
x_test = (0:.005:3)'; | |
n_test = length(x_test); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a batched LSTM forward and backward pass | |
""" | |
import numpy as np | |
import code | |
class LSTM: | |
@staticmethod | |
def init(input_size, hidden_size, fancy_forget_bias_init = 3): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- An exercise to get myself familiar with Agda by formalising category theory | |
--- to the extent that Yoneda lemma can be stated and proved. | |
--- (Agda version 2.6.1 and stdlib 1.3) | |
import Relation.Binary.PropositionalEquality as Eq | |
open Eq using (_≡_; refl; trans; sym; cong; cong-app; subst; cong₂) | |
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) renaming (step-≡ to _≡⟨_⟩_) | |
import Function.Base as Func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, DeriveFunctor #-} | |
-- The usual recursive way of obtaining the initial algebra of a functor f | |
newtype Mu f = In { inOp :: f (Mu f) } | |
cata :: Functor f => (f a -> a) -> Mu f -> a | |
cata alg = alg . fmap (cata alg) . inOp | |
-- Church encoding of initial algebras | |
type Mu' f = forall a . (f a -> a) -> a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, TypeFamilies, DataKinds, TypeOperators, RankNTypes, PolyKinds #-} | |
module HiParser where | |
import Control.Monad.Trans.State.Lazy | |
import GHC.Types | |
-- All types of the parser language: | |
-- BaseTy: every Haskell type is a base type of the parser language | |
-- Arrow: function types of the parser language | |
data Tys = BaseTy GHC.Types.Type | Arrow Tys Tys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, TypeApplications, DataKinds, KindSignatures, GADTs, TypeFamilies #-} | |
-- 1. Parametric higher order abstract syntax (PHOAS) of untyped lambda calculus | |
-------------------- | |
data PTerm p = Var p | Lam (p -> PTerm p) | App (PTerm p) (PTerm p) | |
type Term = forall p . PTerm p | |
-- A semantic domain | |
data Dom = Embed { retract :: Dom -> Dom } |
OlderNewer