Skip to content

Commit ac64d56

Browse files
author
ugik
committed
tflearn examples
1 parent 40301e7 commit ac64d56

File tree

2 files changed

+30
-104
lines changed

2 files changed

+30
-104
lines changed

.ipynb_checkpoints/tflearn toy ANN-checkpoint.ipynb

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,17 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 29,
5+
"execution_count": 36,
66
"metadata": {
77
"collapsed": false
88
},
9-
"outputs": [
10-
{
11-
"data": {
12-
"text/plain": [
13-
"'1.0.1'"
14-
]
15-
},
16-
"execution_count": 29,
17-
"metadata": {},
18-
"output_type": "execute_result"
19-
}
20-
],
21-
"source": [
22-
"import tensorflow as tf\n",
23-
"tf.__version__"
24-
]
25-
},
26-
{
27-
"cell_type": "code",
28-
"execution_count": 1,
29-
"metadata": {
30-
"collapsed": false
31-
},
32-
"outputs": [
33-
{
34-
"name": "stdout",
35-
"output_type": "stream",
36-
"text": [
37-
"hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience)\n"
38-
]
39-
}
40-
],
9+
"outputs": [],
4110
"source": [
4211
"import numpy as np\n",
4312
"import tflearn\n",
4413
"import random\n",
4514
"\n",
46-
"def create_feature_sets_and_labels(test_size = 0.2):\n",
15+
"def create_feature_sets_and_labels():\n",
4716
"\n",
4817
" # known patterns (5 features) output of [1] of positions [0,4]==1\n",
4918
" features = []\n",
@@ -70,36 +39,31 @@
7039
" features.append([[1, 1, 1, 1, 1], [1,0]])\n",
7140
" features.append([[1, 0, 0, 1, 1], [1,0]])\n",
7241
"\n",
73-
" # shuffle out features and turn into np.array\n",
42+
" # shuffle our features and turn into np.array\n",
7443
" random.shuffle(features)\n",
7544
" features = np.array(features)\n",
7645
"\n",
77-
" # split a portion of the features into tests\n",
78-
" testing_size = int(test_size*len(features))\n",
79-
"\n",
8046
" # create train and test lists\n",
81-
" train_x = list(features[:,0][:-testing_size])\n",
82-
" train_y = list(features[:,1][:-testing_size])\n",
83-
" test_x = list(features[:,0][-testing_size:])\n",
84-
" test_y = list(features[:,1][-testing_size:])\n",
47+
" train_x = list(features[:,0])\n",
48+
" train_y = list(features[:,1])\n",
8549
"\n",
86-
" return train_x, train_y, test_x, test_y"
50+
" return train_x, train_y"
8751
]
8852
},
8953
{
9054
"cell_type": "code",
91-
"execution_count": 2,
55+
"execution_count": 37,
9256
"metadata": {
9357
"collapsed": false
9458
},
9559
"outputs": [],
9660
"source": [
97-
"train_x, train_y, test_x, test_y = create_feature_sets_and_labels()"
61+
"train_x, train_y = create_feature_sets_and_labels()"
9862
]
9963
},
10064
{
10165
"cell_type": "code",
102-
"execution_count": 32,
66+
"execution_count": 38,
10367
"metadata": {
10468
"collapsed": false
10569
},
@@ -108,12 +72,11 @@
10872
"name": "stdout",
10973
"output_type": "stream",
11074
"text": [
111-
"Training Step: 999 | total loss: \u001b[1m\u001b[32m0.00214\u001b[0m\u001b[0m | time: 0.003s\n",
112-
"| Adam | epoch: 500 | loss: 0.00214 - acc: 1.0000 -- iter: 16/18\n",
113-
"Training Step: 1000 | total loss: \u001b[1m\u001b[32m0.00209\u001b[0m\u001b[0m | time: 0.006s\n",
114-
"| Adam | epoch: 500 | loss: 0.00209 - acc: 1.0000 -- iter: 18/18\n",
115-
"--\n",
116-
"INFO:tensorflow:/home/gk/gensim/notebooks/ANN.model is not in all_model_checkpoint_paths. Manually adding it.\n"
75+
"Training Step: 999 | total loss: \u001b[1m\u001b[32m0.00434\u001b[0m\u001b[0m | time: 0.003s\n",
76+
"| Adam | epoch: 500 | loss: 0.00434 - acc: 0.9999 -- iter: 16/22\n",
77+
"Training Step: 1000 | total loss: \u001b[1m\u001b[32m0.00429\u001b[0m\u001b[0m | time: 0.006s\n",
78+
"| Adam | epoch: 500 | loss: 0.00429 - acc: 0.9999 -- iter: 22/22\n",
79+
"--\n"
11780
]
11881
}
11982
],

tflearn toy ANN.ipynb

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,17 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 29,
5+
"execution_count": 36,
66
"metadata": {
77
"collapsed": false
88
},
9-
"outputs": [
10-
{
11-
"data": {
12-
"text/plain": [
13-
"'1.0.1'"
14-
]
15-
},
16-
"execution_count": 29,
17-
"metadata": {},
18-
"output_type": "execute_result"
19-
}
20-
],
21-
"source": [
22-
"import tensorflow as tf\n",
23-
"tf.__version__"
24-
]
25-
},
26-
{
27-
"cell_type": "code",
28-
"execution_count": 1,
29-
"metadata": {
30-
"collapsed": false
31-
},
32-
"outputs": [
33-
{
34-
"name": "stdout",
35-
"output_type": "stream",
36-
"text": [
37-
"hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience)\n"
38-
]
39-
}
40-
],
9+
"outputs": [],
4110
"source": [
4211
"import numpy as np\n",
4312
"import tflearn\n",
4413
"import random\n",
4514
"\n",
46-
"def create_feature_sets_and_labels(test_size = 0.2):\n",
15+
"def create_feature_sets_and_labels():\n",
4716
"\n",
4817
" # known patterns (5 features) output of [1] of positions [0,4]==1\n",
4918
" features = []\n",
@@ -70,36 +39,31 @@
7039
" features.append([[1, 1, 1, 1, 1], [1,0]])\n",
7140
" features.append([[1, 0, 0, 1, 1], [1,0]])\n",
7241
"\n",
73-
" # shuffle out features and turn into np.array\n",
42+
" # shuffle our features and turn into np.array\n",
7443
" random.shuffle(features)\n",
7544
" features = np.array(features)\n",
7645
"\n",
77-
" # split a portion of the features into tests\n",
78-
" testing_size = int(test_size*len(features))\n",
79-
"\n",
8046
" # create train and test lists\n",
81-
" train_x = list(features[:,0][:-testing_size])\n",
82-
" train_y = list(features[:,1][:-testing_size])\n",
83-
" test_x = list(features[:,0][-testing_size:])\n",
84-
" test_y = list(features[:,1][-testing_size:])\n",
47+
" train_x = list(features[:,0])\n",
48+
" train_y = list(features[:,1])\n",
8549
"\n",
86-
" return train_x, train_y, test_x, test_y"
50+
" return train_x, train_y"
8751
]
8852
},
8953
{
9054
"cell_type": "code",
91-
"execution_count": 2,
55+
"execution_count": 37,
9256
"metadata": {
9357
"collapsed": false
9458
},
9559
"outputs": [],
9660
"source": [
97-
"train_x, train_y, test_x, test_y = create_feature_sets_and_labels()"
61+
"train_x, train_y = create_feature_sets_and_labels()"
9862
]
9963
},
10064
{
10165
"cell_type": "code",
102-
"execution_count": 32,
66+
"execution_count": 38,
10367
"metadata": {
10468
"collapsed": false
10569
},
@@ -108,12 +72,11 @@
10872
"name": "stdout",
10973
"output_type": "stream",
11074
"text": [
111-
"Training Step: 999 | total loss: \u001b[1m\u001b[32m0.00214\u001b[0m\u001b[0m | time: 0.003s\n",
112-
"| Adam | epoch: 500 | loss: 0.00214 - acc: 1.0000 -- iter: 16/18\n",
113-
"Training Step: 1000 | total loss: \u001b[1m\u001b[32m0.00209\u001b[0m\u001b[0m | time: 0.006s\n",
114-
"| Adam | epoch: 500 | loss: 0.00209 - acc: 1.0000 -- iter: 18/18\n",
115-
"--\n",
116-
"INFO:tensorflow:/home/gk/gensim/notebooks/ANN.model is not in all_model_checkpoint_paths. Manually adding it.\n"
75+
"Training Step: 999 | total loss: \u001b[1m\u001b[32m0.00434\u001b[0m\u001b[0m | time: 0.003s\n",
76+
"| Adam | epoch: 500 | loss: 0.00434 - acc: 0.9999 -- iter: 16/22\n",
77+
"Training Step: 1000 | total loss: \u001b[1m\u001b[32m0.00429\u001b[0m\u001b[0m | time: 0.006s\n",
78+
"| Adam | epoch: 500 | loss: 0.00429 - acc: 0.9999 -- iter: 22/22\n",
79+
"--\n"
11780
]
11881
}
11982
],

0 commit comments

Comments
 (0)