Skip to content

Instantly share code, notes, and snippets.

View kenzotakahashi's full-sized avatar

Kenzo Takahashi kenzotakahashi

  • Tokyo, Japan
View GitHub Profile
@kenzotakahashi
kenzotakahashi / constructWallOutline.js
Last active April 3, 2018 07:39
Construct outlines of walls.
function magnitude(vx, vy) {
return Math.sqrt(vx**2 + vy**2)
}
function slope(x1, y1, x2, y2) {
return (y2 - y1) / (x2 - x1)
}
function isParallel(l1, l2) {
const [[x1,y1],[x2,y2]] = l1
const { GraphQLServer } = require('graphql-yoga')
const mongoose = require('mongoose')
require('dotenv').config()
const resolvers = require('./resolvers')
mongoose.connect(process.env.MONGODB_URI)
const db = mongoose.connection
db.on("error", console.error.bind(console, "connection error"))
db.once("open", function(callback){
console.log("Connection Succeeded")
@kenzotakahashi
kenzotakahashi / policy_gradient.py
Last active August 6, 2018 05:22
Policy Gradient
"""
REINFORCE(Policy Gradient)
"""
import collections
import gym
import numpy as np
import tensorflow as tf
from keras.models import Model
@kenzotakahashi
kenzotakahashi / pytorch_gru.py
Last active February 4, 2020 17:35
PyTorch GRU example with a Keras-like interface.
import numpy as np
from sklearn.model_selection import train_test_split
import torch
import torch.nn as nn
from torch.autograd import Variable
np.random.seed(1337)
MAX_LEN = 30