Skip to content

Instantly share code, notes, and snippets.

View serihiro's full-sized avatar

Kazuhiro Serizawa serihiro

View GitHub Profile
@serihiro
serihiro / simple_thread_safe_queue.py
Created April 29, 2019 01:32
my simple thread safe queue implementation
import os
import sys
import time
import multiprocessing
import threading
import random
class SimpleQueue:
def __init__(self, max_size, response_time=0.1):
self._max_size = max_size
@serihiro
serihiro / queue_per_process_multi_process_test.py
Created April 24, 2019 03:07
Python3 multiprosessing.Queue performance test
import multiprocessing
import os
import sys
import time
import random
def enqueue(_queue, count):
_queue.cancel_join_thread()
for i in range(count):
_queue.put(random.randint(0,count), timeout=1)
@serihiro
serihiro / rmd2r
Created April 21, 2019 09:11
1 liner to convert a Rmd file to a R file
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: rmd2r {input}"
exit 1
fi
Rscript -e "library(knitr);input = commandArgs(trailingOnly=TRUE)[1];purl(input=input)" ${1}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
#!/usr/bin/env python
import argparse
import sys
import numpy as np
import concurrent.futures
import chainer
@serihiro
serihiro / generate_subset_ilsvrc2012.py
Created March 26, 2019 01:39
ILSVRC2012 dataset subset generator
import os
import sys
import argparse
import shutil
def main(train_root, output, img_per_label):
os.makedirs(output, exist_ok=True)
for label in os.listdir(train_root):
print(label)
@serihiro
serihiro / note.md
Last active February 1, 2019 07:39
chainer-compilerのビルドメモ

環境

  • MacOS10.14.2
  • python3.6.4
  • clang/clang++ Apple LLVM version 10.0.0 (clang-1000.11.45.5)

手順

  • git clone
  • リポジトリのroot directoryで setup.sh を実行
  • chainer-compiler用のvenvを作成してactivate
  • submoduleとしてchainerとonnxのリポジトリがfetchされたので、それぞれのディレクトリで pip install -e .
@serihiro
serihiro / how_to_select_fpga_board.md
Created January 28, 2019 03:44
研究室の先輩から教わったFPGAボードの選び方
  1. Xilinx or Intelどちらに入信するか決めます
  2. 初心者のうちは、FPGAはボード毎にそれぞれおまったく別物と考えるべきです
  3. 「そのボード」に関して、ぐぐってよく情報が出てくるものをおすすめします

すなわち、やりたい事をしていた人が使っていたからそのボードを選ぶのではなく、 広くみんなに使われていて、ぐぐったときに情報がでやすい物がいいと思います

極端な話、細かい最適化を除けば、Verilogコードはギリギリ可搬性があるが、 ボード固有の情報は全く可搬性がないので、自分で解決できなさそうならば、情報入手性が高いものが良い

@serihiro
serihiro / settings.json
Last active January 13, 2022 05:59
情報処理学会用latex設定 for latex-workshop
{
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-e",
"$latex=q/platex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/",
"-e",
@serihiro
serihiro / cifar100_to_png.py
Created January 7, 2019 00:03
Converter for Cifar100 pickle data to png
from PIL import Image
import numpy as np
import pickle
import argparse
import os
metadata_dict = None
def unpickle(file_path):