This file contains 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 matplotlib.pyplot as plt | |
import os | |
%matplotlib inline | |
tf.reset_default_graph() | |
images = "dataset/test_dataset_png/" | |
image_dir = os.path.join(os.getcwd(), images) | |
imagenames = [os.path.join(image_dir, f) for f in os.listdir(image_dir)] |
This file contains 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 matplotlib.pyplot as plt | |
import os | |
%matplotlib inline | |
tf.reset_default_graph() | |
images = "dataset/test_dataset_png/" | |
image_dir = os.path.join(os.getcwd(), images) | |
imagenames = [os.path.join(image_dir, f) for f in os.listdir(image_dir)] |
This file contains 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 | |
def input_fn(): | |
up = [i for i in range(10)] | |
down = [9-i for i in range(10)] | |
features = tf.constant([up if i%2 == 0 else down for i in range(1000)], tf.float32) | |
label = tf.constant([[1] if i%2 == 0 else [0] for i in range(1000)], tf.float32) | |
return features, label | |
def model(features, labels, mode): |
This file contains 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
def input_fn(): | |
up = [i for i in range(10)] | |
down = [9-i for i in range(10)] | |
features = tf.constant([up if i%2 == 0 else down for i in range(1000)], tf.float32) | |
label = tf.constant([[1] if i%2 == 0 else [0] for i in range(1000)], tf.float32) | |
return features, label |
This file contains 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
def model(features, labels, mode): | |
layer1 = tf.layers.dense(features, 10) | |
layer2 = tf.layers.dense(layer1, 10) | |
layer3 = tf.layers.dense(layer2, 10) | |
layer4 = tf.layers.dense(layer3, 10) | |
out = tf.layers.dense(layer4, 1) | |
global_step = tf.train.get_global_step() | |
loss = tf.losses.sigmoid_cross_entropy(labels, out) | |
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(loss, global_step) |
This file contains 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
est = tf.estimator.Estimator(model) | |
est.train(input_fn, steps=5) |
This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
tf.reset_default_graph() | |
sample = 1000 | |
x = np.array([0.01*float(i) for i in range(sample+1)], np.float32) | |
y = np.sin(x) |
This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
tf.reset_default_graph() | |
# hyper parameters | |
samples = 1000 | |
time_step = 100 |
This file contains 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 os | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
file_dir = os.path.join(os.getcwd(), "dataset/test_dataset_png") | |
image_paths = [os.path.join(file_dir, i) for i in os.listdir(file_dir)] | |
This file contains 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
def gen_dataset(): | |
up = [i for i in range(10)] | |
down = [9-i for i in range(10)] | |
with open("./test.csv", 'w') as f: | |
writer = csv.writer(f, delimiter=",") | |
for i in range(5): | |
writer.writerow([1] + up) | |
writer.writerow([0] + down) |