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
in_a = tf.placeholder(dtype=tf.float32, shape=(2)) | |
in_b = tf.placeholder(dtype=tf.float32, shape=(2)) | |
def forward(x): | |
with tf.variable_scope("matmul", reuse=tf.AUTO_REUSE): | |
W = tf.get_variable("W", initializer=tf.ones(shape=(2,2)), | |
regularizer=tf.contrib.layers.l2_regularizer(0.04)) | |
b = tf.get_variable("b", initializer=tf.zeros(shape=(2))) | |
return W * x + b |
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
# TensorFlow 1.X | |
outputs = session.run(f(placeholder), feed_dict={placeholder: input}) | |
# TensorFlow 2.0 | |
outputs = f(input) |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.gridspec as gridspec | |
import imgaug as ia | |
import imgaug.augmenters as iaa | |
# draw single image | |
def drawImage(figureName, image): | |
plt.figure(num=figureName) | |
plt.imshow(image / 255) # 0-1 float normalize |
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
""" | |
Cartpole Policy Gradient Example using TensorFlow 2.0 | |
Reference : https://github.com/awjuliani/DeepRL-Agents/blob/master/Vanilla-Policy.ipynb | |
Author : solaris33 | |
Project URL : http://solarisailab.com/archives/2652 | |
""" | |
import tensorflow as tf |
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
# -*- coding: utf-8 -*- | |
# Convolutional Neural Networks(CNN)을 이용한 MNIST 분류기(Classifier) - Keras API를 이용한 구현 | |
import tensorflow as tf | |
# MNIST 데이터를 다운로드 합니다. | |
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() | |
# 이미지들을 float32 데이터 타입으로 변경합니다. | |
x_train, x_test = x_train.astype('float32'), x_test.astype('float32') | |
# 28*28 형태의 이미지를 784차원으로 flattening 합니다. |
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 (C) # | |
# 2016-2018 Shangtong Zhang([email protected]) # | |
# 2016 Kenta Shimada([email protected]) # | |
# Permission given to modify the code as long as you keep this # | |
# declaration at the top # | |
####################################################################### | |
# Refactoring : solaris33 | |
import matplotlib |
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
import tensorflow as tf | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import functools | |
from PIL import Image | |
""" | |
TensorFlow Data Augmentation Example | |
Reference : https://github.com/tensorflow/models/blob/master/research/object_detection/core/preprocessor.py |
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
# reference : https://github.com/keras-team/keras/blob/master/examples/mnist_mlp.py | |
'''Trains a simple deep NN on the MNIST dataset. | |
Gets to 98.40% test accuracy after 20 epochs | |
(there is *a lot* of margin for parameter tuning). | |
2 seconds per epoch on a K520 GPU. | |
''' | |
from __future__ import print_function |
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
#-*- coding: utf-8 -*- | |
""" | |
TFRecords Example | |
Reference : https://www.tensorflow.org/tutorials/load_data/tf_records | |
Author : solaris33 | |
Project URL : http://solarisailab.com/archives/2603 | |
""" | |
from __future__ import absolute_import, division, print_function, unicode_literals |
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
import tensorflow as tf | |
i = tf.constant(1) | |
j = tf.constant(1) | |
k = tf.constant(1) | |
def cond(i, j, k): | |
return tf.less(i, 10) | |
def body(i, j, k): |