Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devanshdalal/1928d5b5abdb271e18afce9fe4776ade to your computer and use it in GitHub Desktop.
Save devanshdalal/1928d5b5abdb271e18afce9fe4776ade to your computer and use it in GitHub Desktop.
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