Skip to content

Instantly share code, notes, and snippets.

View crcrpar's full-sized avatar

Masaki crcrpar

  • NVIDIA
  • Tokyo
  • 11:38 (UTC +09:00)
View GitHub Profile
@crcrpar
crcrpar / Dockerfile
Created May 5, 2019 04:58
Development environment of Chainer
FROM nvidia/cuda:10.0-cudnn7-devel
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
python3-dev \
python3-pip \
python3-wheel \
python3-setuptools \
git \
cmake \
@crcrpar
crcrpar / attention_augmented_convolution2d.py
Last active May 8, 2019 03:44
attention augmented convolution in Chainer
import typing
import chainer
from chainer import functions
from chainer import links
from chainer import types
class AttentionAugmentedConvolution2D(chainer.Chain):
@crcrpar
crcrpar / xenial-5.0.1-sourcekit.Dockerfile
Last active June 25, 2019 15:02
Dockerfile for Swift 5.0.1 with Sourcekit
FROM swift:5.0.1-xenial
# Install git, process tools
RUN rm -rf /var/lib/apt/lists/* \
&& apt-get update -y \
&& apt-get -y --no-install-recommends install \
git \
procps \
aria2 \
libsqlite3-dev \
@crcrpar
crcrpar / function_pointer.cpp
Created June 14, 2019 14:31
Some playing with C++ function pointers (cpp14)
#include <algorithm>
#include <iostream>
#include <vector>
int * func1(int * x, int n) {
// for (int i = 0; i < ++n; ++i) {
for (int i = 0; i < n; ++i) {
std::cout << "i = " << i << ", x = " << x << std::endl;
++(*(x++));
// /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2019-06-17-a.xctoolchain
import TensorFlow
public struct SNConv2D<Scalar: TensorFlowFloatingPoint>: Layer {
// Avoid below errors:
// TensorFlow.Layer:2:20: note: protocol requires nested type 'Input'; do you want to add it?
// TensorFlow.Layer:3:20: note: protocol requires nested type 'Output'; do you want to add it?
public typealias Input = Tensor<Scalar>
@crcrpar
crcrpar / crtpExample.cpp
Created July 18, 2019 03:46
Curiously Recurring Template Pattern
/*
* Introduction to Curiously Recurring Template Pattern
*
* Ref: https://theolizer.com/cpp-school2/cpp-school2-19/
*/
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <tuple>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crcrpar
crcrpar / SNGAN_Discriminator_32_64.ipynb
Created July 26, 2019 17:35
Swift for TensorFlow implementation of SNConv2D, SNDense, Blocks, and Models
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crcrpar
crcrpar / sngan_cifar-10.ipynb
Last active July 26, 2019 17:40
Spectral Normalization GAN on CIFAR-10
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# data: fastai's DataBunch
def objective(trial: optuna.Trial):
num_layers = trial.suggest_int('n_layers', 1, 5) # `num_layers` is 1, 2, 3, 4, or 5.
layers, ps = [], [] # define the number of unit of each layer / the ratio of dropout of each layer
for i in range(n_layers - 1): # `TabularModel` automatically adds the last layer.
num_units = trial.suggest_categorical(f'num_units_layer_{i}', [800, 900, 1000, 1100, 1200])
p = trial.suggest_discrete_uniform(f'dropout_p_layer_{i}', 0, 1, 0.05)
layers.append(num_units); ps.append(p)