Created
January 27, 2017 17:28
-
-
Save devanshdalal/1928d5b5abdb271e18afce9fe4776ade to your computer and use it in GitHub Desktop.
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
from __future__ import division, print_function, absolute_import | |
import numpy as np | |
import tflearn | |
import tensorflow as tf | |
from tflearn.data_utils import to_categorical, pad_sequences | |
from tflearn.datasets import imdb | |
# IMDB Dataset loading | |
M=10000 | |
X=np.random.rand(M,5) | |
Y= np.array([ [sum(x**2)/len(x),sum(x)/len(x)] for x in X ]) | |
print('X',X) | |
print('Y',Y) | |
# Network building | |
net = tflearn.input_data([None, 5]) | |
net = tflearn.fully_connected(net, 64, activation='linear', | |
regularizer='L2', weight_decay=0.0005) | |
# net = tflearn.embedding(net, input_dim=100, output_dim=128) | |
# net = tflearn.lstm(net, 128, dropout=0.1) | |
net = tflearn.fully_connected(net, 2, activation='linear') | |
net = tflearn.regression(net, optimizer= | |
tflearn.optimizers.AdaGrad(learning_rate=0.01, initial_accumulator_value=0.01), | |
loss='mean_square', learning_rate=0.05) | |
# Training | |
model = tflearn.DNN(net, tensorboard_verbose=0, checkpoint_path='tmp/') | |
model.fit(X, Y, show_metric=True, | |
batch_size=100) | |
print("res",model.predict([X[-1]]),[Y[-1]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment