This file contains hidden or 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
# | |
# Copyright 2017 Koichi Akabe | |
# License: GPLv3+ | |
# | |
import numpy as np | |
cimport numpy as np | |
#DTYPE = np.int32 | |
#ctypedef np.int32_t DTYPE_t |
This file contains hidden or 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
#!/usr/bin/env python3 | |
from itertools import chain | |
def ranges_or(ranges): | |
result = [] | |
depth = 0 | |
for p, t in sorted(chain.from_iterable(((x, -1), (y, 1)) for x, y in ranges)): | |
if depth == 0 and t == -1: |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Efficient online and batch learning using forward backward splitting | |
# John Duchi and Yoram Singer | |
# Journal of Machine Learning Research 10 (2009) 2899-2934 | |
# http://www.jmlr.org/papers/volume10/duchi09a/duchi09a.pdf | |
# Efficient Elastic Net Regularization for Sparse Linear Models | |
# Zachary C. Lipton and Charles Elkan (2015) | |
# https://arxiv.org/pdf/1505.06449.pdf |
This file contains hidden or 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
#!/usr/bin/env python3 | |
from typing import TypeVar, Generic, Any, List | |
from abc import ABCMeta, abstractmethod | |
from itertools import dropwhile, zip_longest | |
def euclid_gcd(a, b): | |
x = a.zero() | |
y = a.identity() |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# | |
# Burrows Wheeler Transform implemented in Python | |
# Currently, list.sort() is not the radix sort, so the algorithm order is O(n log n log n). | |
# This algorithm replaces items of arr to integers, so we can use the radix sort instead. | |
# In that case, the algorithm order becomes O(n log n). | |
# | |
from operator import itemgetter |
This file contains hidden or 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
#define REDUCE(k, GROUP_SIZE) \ | |
if (GROUP_SIZE >= k << 1) { \ | |
if (tid < k) { \ | |
if (max_val[tid + k] > max_val[tid]) { \ | |
max_val[tid] = max_val[tid + k]; \ | |
argmax_val[tid] = argmax_val[tid + k]; \ | |
} \ | |
} \ | |
barrier(CLK_LOCAL_MEM_FENCE); \ | |
} |
This file contains hidden or 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
(ns xor-example.core | |
(:import | |
[primitiv Device Graph Parameter Shape] | |
[primitiv functions functions$batch] | |
[primitiv.devices Naive] | |
[primitiv.initializers XavierUniform Constant] | |
[primitiv.optimizers SGD])) | |
(defn -main [] |
This file contains hidden or 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
#!/bin/bash -xe | |
ABSPATH=$(realpath $0) | |
DIRNAME=$(dirname ${ABSPATH}) | |
ANDROID_NDK_PATH=/path/to/Android/Sdk/ndk-bundle | |
ANDROID_ABI=armeabi-v7a | |
ANDROID_PLATFORM=android-15 | |
OPENCL_INCLUDE_DIR=${DIRNAME}/OpenCL/include | |
OPENCL_LIBRARY=${DIRNAME}/OpenCL/lib/libOpenCL.so |
This file contains hidden or 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
#include <algorithm> | |
#include <chrono> | |
#include <functional> | |
#include <iostream> | |
#include <random> | |
#define CL_HPP_ENABLE_EXCEPTIONS | |
#define CL_HPP_MINIMUM_OPENCL_VERSION 120 | |
#define CL_HPP_TARGET_OPENCL_VERSION 120 | |
#define CL_HPP_CL_1_2_DEFAULT_BUILD |
This file contains hidden or 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
use std::cell::RefCell; | |
use std::rc::Rc; | |
use html5ever::{Attribute, LocalName, QualName}; | |
use html5ever::driver::ParseOpts; | |
use html5ever::{local_name, ns, namespace_url}; | |
use html5ever::{parse_document, parse_fragment}; | |
use html5ever::rcdom::{Handle, Node, NodeData, RcDom}; | |
use html5ever::serialize; | |
use html5ever::serialize::SerializeOpts; |