Skip to content

Instantly share code, notes, and snippets.

@ByungSunBae
ByungSunBae / DRLpytorch_Atari.py
Last active August 9, 2017 05:43
Deep Reinforcement Learning : Deep Q Network(DQN) and Variants (Double DQN, Dueling DQN)
# Thanks for 주찬웅
# References:
## 1) https://github.com/jcwleo/Reinforcement_Learning/blob/master/Breakout/
## 2) http://pytorch.org/tutorials/
## 3) https://github.com/transedward/pytorch-dqn
## My codes is very very dirty...
## I want to your idea and advice that improves this codes.
import argparse
@ByungSunBae
ByungSunBae / PolicyGradient.markdown
Last active January 30, 2020 13:10
Policy Gradient

DRL : Policy Gradient

Overview

  • Deep Q network(이하 DQN)와 그 Variants(DoubleDQN, DuelingDQN)를 구현해보았다.

  • 그런데 DQN과 같은 계열의 방법은 RL에서 Value-Based Method라서 Policy에 대한 직접적인 학습이 아니다.

  • 게다가 Value가 약간만 바뀌어도 Policy가 금방 변한다.

  • 학습과정이 불안정하게되어 수렴자체가 불안정해진다. (Bias가 높다.)

@ByungSunBae
ByungSunBae / predict_counts.R
Created September 19, 2017 09:40
RNN using Tensorflow in R
# 2) RNN model 생성----------------
## Refer : https://github.com/hunkim/DeepLearningZeroToAll/blob/master/lab-12-5-rnn_stock_prediction.py
library(tensorflow)
library(reticulate)
contrib <- tf$contrib
tf$reset_default_graph()
# train Parameters
@ByungSunBae
ByungSunBae / CVXR_tutorial.R
Last active November 29, 2017 00:18
Following CVXR package tutorial : Convex Optimization in R
## Convex Optimization in R using CVXR
## from : https://rviews.rstudio.com/2017/11/27/introduction-to-cvxr/
## load CVXR
if (!require(CVXR)){
install.packages("CVXR")
} else{
require(CVXR)
}
@ByungSunBae
ByungSunBae / EditGraph.py
Created December 5, 2017 09:18
simple tensorflow graph edit example
# from : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/graph_editor/examples/edit_graph_example.py
import numpy as np
import tensorflow as tf
from tensorflow.contrib import graph_editor as ge
# create a graph
g = tf.Graph()
with g.as_default():
@ByungSunBae
ByungSunBae / A2Cpytorch_Atari.py
Created December 5, 2017 09:28
A2C pytorch version
# References:
import argparse
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.transforms as T
@ByungSunBae
ByungSunBae / Continuous_A2C_test.py
Created December 28, 2017 15:07
A2C with continuous action space test
import tensorflow as tf
from tensorflow import layers
from tensorflow.contrib.layers import xavier_initializer
import gym
import numpy as np
from collections import deque
from collections import namedtuple
@ByungSunBae
ByungSunBae / jaccard_sim_starwars.R
Created August 12, 2018 16:13
영화별 자카드 유사도 계산 및 시각화 퀴즈
# 스타워즈 시리즈들의 유사도를 등장인물들을 통해 계산하고 시각화 하는 문제
# From : https://github.com/R-Korea/weekly_R_quiz/blob/master/201808/1.movie_similarity/movie_similarity_quiz.Rmd
library(dplyr)
library(data.table)
library(ggplot2)
library(scales)
rm(list=ls())
raw.data <-
@ByungSunBae
ByungSunBae / greedy_algorithm.go
Last active January 24, 2019 01:30
탐욕알고리즘(greedy algorithm)으로 풀어보는 (간단한) 음식 선택하기 - Golang version
// From : https://www.edwith.org/datascience/lecture/33888/
// edwith에서 한글자막을 달아놓은 MIT의 Data Science 강좌중 첫번째 챕터입니다.
// 위 링크에서 파이썬 버전의 코드를 받아보실 수 있습니다.
// 칼로리가 제한될 때, 음식을 선택하는 문제를 탐욕 알고리즘으로 푸는 문제입니다.
// 파이썬 코드를 Golang으로 변환했습니다.
package main
import (
"flag"
@ByungSunBae
ByungSunBae / simple_op.go
Created January 29, 2019 13:54
tensorflow simple operation in golang (key point : sum of elements of vector)
package main
import (
"fmt"
"github.com/kniren/gota/dataframe"
tf "github.com/tensorflow/tensorflow/tensorflow/go"
"github.com/tensorflow/tensorflow/tensorflow/go/op"
"os"
)