@@ -0,0 +1,1272 @@
+# embedding words using dictionary util: https://github.com/tflearn/tflearn/issues/124%0A# load pretrained wordvec: https://github.com/tflearn/tflearn/issues/35%0Afrom pprint import pprint as pp%0Aimport tflearn%0Afrom tflearn.data_utils import pad_sequences, to_categorical%0Afrom tflearn.datasets import imdb%0A%0Atrain, test, _ = imdb.load_data(%0A    path='data/imdb.pkl', n_words=10000, valid_portion=0.1)%0AtrainX, trainY = train%0AtestX, testY = test%0A%0A%0A# Data preprocessing%0A# sequence padding%0AtrainX = pad_sequences(trainX, maxlen=100, value=0.)%0AtestX = pad_sequences(testX, maxlen=100, value=0.)%0A# binarizer, increase rank%0AtrainY = to_categorical(trainY, nb_classes=2)%0AtestY = to_categorical(testY, nb_classes=2)%0A%0A%0A# words -%3E vocab id transform -%3E embedding%0Adef run():%0A    net = tflearn.input_data(%5BNone, 100%5D)%0A    net = tflearn.embedding(net, input_dim=10000, output_dim=128)%0A    net = tflearn.lstm(net, 128, dropout=0.8)%0A    net = tflearn.fully_connected(net, 2, activation='softmax')%0A    net = tflearn.regression(net, optimizer='adam',%0A                             learning_rate=0.001,%0A                             loss='categorical_crossentropy')%0A%0A    m = tflearn.DNN(net)%0A    m.fit(trainX, trainY, validation_set=(testX, testY),%0A          show_metric=True, batch_size=32)%0A%0Arun()%0A

add simple lstm with imdb