Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the to_categorical in the data_utils.py #950

Open
wants to merge 61 commits into
base: 0.3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
8ce65f4
add contrastive loss (#801)
willduan Jun 18, 2017
8af77b5
Fix tflearn.activation on callable object (#805)
Enet4 Jun 22, 2017
912cdc3
fixed typo (#807)
Jaxing Jun 29, 2017
d93a32e
L2 nofm fix for tensorflow 1.0 (#810)
Ruslanmlnkv Jun 29, 2017
644ecd4
Fix function to_categorical in data_utils.py (#816)
Jul 7, 2017
d01a0b9
Fix `bidirectional_rnn` with TF >= 1.2 (resolves #818) (#825)
colinskow Jul 10, 2017
6fd2a9d
Fix "using a `tf.Tensor` as a Python `bool` is not allowed" (#820)
willduan Jul 12, 2017
b52030a
Fix problem with excluding training ops (#835)
exelents Jul 12, 2017
af57b17
update:recommender_wide_and_deep.py (#838)
Shuolongbj Jul 14, 2017
9d48f42
add densenet layer & example
aymericdamien Jul 25, 2017
6d6c8a6
densenet fixes
aymericdamien Jul 26, 2017
6b05603
fix bug
aymericdamien Jul 26, 2017
d28030a
fix elu activation function (#853)
ZhengyaoJiang Jul 29, 2017
6669cc8
fixed error on summaries (#846)
windog18 Aug 5, 2017
8f12d06
Fix Grayscale Image Shape (#869)
Torrencem Aug 13, 2017
bf9dbbc
Coding format! (#877)
Amitayus Aug 21, 2017
b69546b
When using the image_preloader the images can be loaded from an URL. …
legor Sep 1, 2017
cca486c
fix py2 comp
aymericdamien Sep 1, 2017
b6d2eb4
fix #892 (numpy weights compatibility)
aymericdamien Sep 1, 2017
3e0c329
[Docs] Convolution layers: Typo fixes (#903)
ChrisOelmueller Sep 19, 2017
16a3bbc
convert RGBA to RGB in build_hdf5_image_dataset (#904)
ilaripih Sep 20, 2017
06067cc
Fixes the seq2seq example (#916)
cpbrust Sep 26, 2017
82efb41
remove the redundant parentheses (#925)
gaotianxiang Oct 9, 2017
8c1feff
s/indexies/indices/ (#937)
jbn Oct 17, 2017
2f5853c
Improve to_categorical function (#923)
herossa Oct 19, 2017
f6a947f
update to_categorical
aymericdamien Oct 19, 2017
72bb85a
rnn return_seq as 3d-tensor (#953)
kykosic Nov 15, 2017
0fb2a2d
Adding an upscore_layer for 3D. (#973)
plooney Dec 12, 2017
0989660
[WIP] new estimators (#994)
aymericdamien Jan 9, 2018
83d08d1
fix bug
aymericdamien Jan 9, 2018
379eeb3
fix compatibility issues
aymericdamien Jan 11, 2018
b222527
minor fix
aymericdamien Jan 11, 2018
184d753
added default parameter for weight (#997)
aymericdamien Jan 15, 2018
b1a34ae
VGG19 Network and weights (#1003)
AhmetHamzaEmra Jan 24, 2018
70fb38a
Extract method from duplicate code in dnn (#1010)
selcouthlyBlue Feb 11, 2018
81ca9a8
Tensorflow updated the attribute (#1024)
AhmetHamzaEmra Mar 22, 2018
f80e4af
Fixing tflearn examples to work with newer versions (#1031)
DollarAkshay Mar 31, 2018
f81fcec
Update merge_ops.py (#1050)
Andy1621 Jun 1, 2018
fead80d
fix typo (#1057)
fraxmans Jun 1, 2018
8aa8436
Fix typo (#1059)
Jun 14, 2018
5a674b7
Make exception more informative (#1068)
ChemicalXandco Jul 1, 2018
29f08d1
Speed up importing (#1070)
akx Jul 1, 2018
6934f5c
quick fix
aymericdamien Jul 27, 2018
13b04e4
fixed directory mismatch in cifar10 loaddata (#1084)
llucid-97 Aug 23, 2018
e532c85
Add support for image base path and float labels in image_preloader()…
kecsap Sep 9, 2018
c0baee9
fix typo (#1090)
angrypark Sep 25, 2018
fa93b40
Update SELU (#1092)
aymericdamien Oct 17, 2018
cffd677
Fixing termlogs for R2 (#1093)
vishalshar Oct 27, 2018
ecbecc8
Adding hard sigmoid activation function (#1095)
vishalshar Nov 2, 2018
ce47436
fix r2_op to match sklearn.metrics.r2_score (#1100)
ilaripih Nov 28, 2018
d6d7dc9
use a separate saver for "best validation accuracy" models (#1103)
ilaripih Dec 14, 2018
f18af5c
Do not install tests in site-packages (#1104)
cgohlke Dec 15, 2018
5c23566
Adding GELUs activation function (#1113)
vishalshar Jan 10, 2019
6e38143
TFLearn v0.5.0 Release (#1157)
aymericdamien Nov 11, 2020
aac7ce6
Fixes for 0.5.0 (#1158)
aymericdamien Nov 11, 2020
623ed92
add swish activation function (#1155)
Hemantr05 Nov 11, 2020
e7148af
merge (#1159)
aymericdamien Nov 11, 2020
dc31ec0
Fix syntax warning over comparison of literals using is. (#1150)
tirkarthi Nov 11, 2020
a497518
Added fashion_mnist dataset (#1160)
Hemantr05 Nov 14, 2020
0f44f97
Adding triplet loss (#1161)
Hemantr05 Nov 24, 2020
db51767
fix indent
aymericdamien Nov 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion ACKNOWLEDGMENTS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ TFLearn was created to provide a new transparent and simple interface over Tenso

- [TensorFlow](http://tensorflow.org) for some derivated code (copyright below). As a higher-level API, TFLearn is heavily relying on TensorFlow base API.
- [TensorFlow models](https://github.com/tensorflow/models).
- [Lasagne](https://github.com/Lasagne/Lasagne) (MIT License) TFLearn model building concept with layers is directly inspired from Lasagne. While Lasagne only support Theano, TFLearn is aiming at providing similar concept over TensorFlow instead.
- [SKLearn](http://scikit-learn.org) (NEW BSD License) TFLearn estimators are an adaptation of SKLearn in TensorFLow, as such, TFLearn reuses some structure and documentation from it.
- [Lasagne](https://github.com/Lasagne/Lasagne) (MIT License) Originally, TFLearn neural network building concept is directly inspired from Lasagne. While Lasagne only support Theano, TFLearn is aiming at providing similar concept over TensorFlow instead.
- [Keras](http://keras.io) (MIT License) A few layers structure.

# TensorFlow is subject to the following copyright notice:
Expand Down Expand Up @@ -210,3 +211,37 @@ Copyright 2015 The TensorFlow Authors. All rights reserved.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

# SKLearn is subject to the following license:

New BSD License

Copyright (c) 2007–2017 The scikit-learn developers.
All rights reserved.


Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

a. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
b. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
c. Neither the name of the Scikit-learn Developers nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TFLearn features include:

The high-level API currently supports most of recent deep learning models, such as Convolutions, LSTM, BiRNN, BatchNorm, PReLU, Residual networks, Generative networks... In the future, TFLearn is also intended to stay up-to-date with latest deep learning techniques.

Note: Latest TFLearn (v0.3) is only compatible with TensorFlow v1.0 and over.
Note: Latest TFLearn (v0.5) is only compatible with TensorFlow v2.0 and over.

## Overview
```python
Expand Down Expand Up @@ -50,11 +50,18 @@ model.generate(50, temperature=1.0)

There are many more examples available *[here](http://tflearn.org/examples)*.

## Compatibility
TFLearn is based on the original tensorflow v1 graph API. When using TFLearn, make sure to import tensorflow that way:
```
import tflearn
import tensorflow.compat.v1 as tf
```

## Installation

**TensorFlow Installation**

TFLearn requires Tensorflow (version 1.0+) to be installed.
TFLearn requires Tensorflow (version 2.0+) to be installed.

To install TensorFlow, simply run:
```
Expand All @@ -65,7 +72,7 @@ or, with GPU-support:
pip install tensorflow-gpu
```

For more details see *[TensorFlow installation instructions](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md)*
For more details see *[TensorFlow installation instructions](https://www.tensorflow.org/install)*

**TFLearn Installation**

Expand Down
19 changes: 19 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Release 0.5.0

Major changes:
- TensorFlow 2.3.0 support
- Refactoring source to use tf.compat.v1

Minor changes:
- Update documentation
- Various bug fix

# Release 0.4.0

Major changes:
- Added new estimators (RandomForest, KMeans)

Minor changes:
- Added distance ops
- Various bug fix

# Release 0.3.2

Major changes:
Expand Down
4 changes: 2 additions & 2 deletions docs/autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from tflearn import objectives
from tflearn import optimizers
from tflearn import data_utils
from tflearn import losses
from tflearn import regularizers
from tflearn import summaries
from tflearn import utils
from tflearn import variables
Expand Down Expand Up @@ -48,7 +48,7 @@
(objectives, 'tflearn.objectives'),
(optimizers, 'tflearn.optimizers'),
(data_utils, 'tflearn.data_utils'),
(losses, 'tflearn.losses'),
(regularizers, 'tflearn.regularizers'),
(summaries, 'tflearn.summaries'),
(variables, 'tflearn.variables'),
(utils, 'tflearn.utils'),
Expand Down
4 changes: 3 additions & 1 deletion docs/templates/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
- [Highway Convolutional Network](https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_highway_mnist.py). Highway Convolutional Network implementation for classifying MNIST dataset.
- [Residual Network (MNIST)](https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py). A bottleneck residual network applied to MNIST classification task.
- [Residual Network (CIFAR-10)](https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py). A residual network applied to CIFAR-10 classification task.
- [ResNeXt (CIFAR-10)](https://github.com/tflearn/tflearn/blob/master/examples/images/resnext_cifar10.py). Aggregated residual transformations network (ResNeXt) applied to CIFAR-10 classification task.
- [ResNeXt](https://github.com/tflearn/tflearn/blob/master/examples/images/resnext_cifar10.py). Aggregated residual transformations network (ResNeXt) applied to CIFAR-10 classification task.
- [DenseNet](https://github.com/tflearn/tflearn/blob/master/examples/images/densenet.py). A densely connected convolutional network applied to CIFAR-10 classification task.
- [Google Inception (v3)](https://github.com/tflearn/tflearn/blob/master/examples/images/googlenet.py). Google's Inception v3 network applied to Oxford Flowers 17 classification task.

### Unsupervised
- [Auto Encoder](https://github.com/tflearn/tflearn/blob/master/examples/images/autoencoder.py). An auto encoder applied to MNIST handwritten digits.
- [Variational Auto Encoder](https://github.com/tflearn/tflearn/blob/master/examples/images/variational_autoencoder.py). A Variational Auto Encoder (VAE) trained to generate digit images.
Expand Down
2 changes: 1 addition & 1 deletion docs/templates/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ File | Layers

### Built-in Operations

Besides layers concept, TFLearn also provides many different ops to be used when building a neural network. These ops are firstly mean to be part of the above 'layers' arguments, but they can also be used independently in any other Tensorflow graph for convenience. In practice, just providing the op name as argument is enough (such as activation='relu' or regularizer='L2' for conv_2d), but a function can also be provided for further customization.
Besides layers concept, TFLearn also provides many different ops to be used when building a neural network. These ops are firstly meant to be part of the above 'layers' arguments, but they can also be used independently in any other Tensorflow graph for convenience. In practice, just providing the op name as argument is enough (such as activation='relu' or regularizer='L2' for conv_2d), but a function can also be provided for further customization.

File | Ops
-----|----
Expand Down
4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
- [Alexnet](https://github.com/tflearn/tflearn/blob/master/examples/images/alexnet.py). Apply Alexnet to Oxford Flowers 17 classification task.
- [VGGNet](https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py). Apply VGG Network to Oxford Flowers 17 classification task.
- [VGGNet Finetuning (Fast Training)](https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network_finetuning.py). Use a pre-trained VGG Network and retrain it on your own data, for fast training.
- [VGG19](https://github.com/AhmetHamzaEmra/tflearn/blob/master/examples/images/VGG19.py). Apply VGG19 Network to ImageNet classification task.
- [RNN Pixels](https://github.com/tflearn/tflearn/blob/master/examples/images/rnn_pixels.py). Use RNN (over sequence of pixels) to classify images.
- [Highway Network](https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py). Highway Network implementation for classifying MNIST dataset.
- [Highway Convolutional Network](https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_highway_mnist.py). Highway Convolutional Network implementation for classifying MNIST dataset.
- [Residual Network (MNIST)](https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py). A bottleneck residual network applied to MNIST classification task.
- [Residual Network (CIFAR-10)](https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py). A residual network applied to CIFAR-10 classification task.
- [ResNeXt (CIFAR-10)](https://github.com/tflearn/tflearn/blob/master/examples/images/resnext_cifar10.py). Aggregated residual transformations network (ResNeXt) applied to CIFAR-10 classification task.
- [ResNeXt](https://github.com/tflearn/tflearn/blob/master/examples/images/resnext_cifar10.py). Aggregated residual transformations network (ResNeXt) applied to CIFAR-10 classification task.
- [DenseNet](https://github.com/tflearn/tflearn/blob/master/examples/images/densenet.py). A densely connected convolutional network applied to CIFAR-10 classification task.
- [Google Inception (v3)](https://github.com/tflearn/tflearn/blob/master/examples/images/googlenet.py). Google's Inception v3 network applied to Oxford Flowers 17 classification task.
### Unsupervised
- [Auto Encoder](https://github.com/tflearn/tflearn/blob/master/examples/images/autoencoder.py). An auto encoder applied to MNIST handwritten digits.
Expand Down
26 changes: 26 additions & 0 deletions examples/basics/kmeans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
""" K-Means Example """

from __future__ import division, print_function, absolute_import

from tflearn.estimators import KMeans

# Data loading and preprocessing
import tflearn.datasets.mnist as mnist
X, Y, testX, testY = mnist.load_data(one_hot=False)

# K-Means training
m = KMeans(n_clusters=10, distance='squared_euclidean')
m.fit(X, display_step=10)

# Testing
print("Clusters center coordinates:")
print(m.cluster_centers_vars)

print("X[0] nearest cluster:")
print(m.labels_[0])

print("Predicting testX[0] nearest cluster:")
print(m.predict(testX[0]))

print("Transforming testX[0] to a cluster-distance space:")
print(m.transform(testX[0]))
2 changes: 1 addition & 1 deletion examples/basics/logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from __future__ import absolute_import, division, print_function

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn

# Logical NOT operator
Expand Down
24 changes: 24 additions & 0 deletions examples/basics/random_forest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
""" Random Forest example. """

from __future__ import division, print_function, absolute_import

import tflearn
from tflearn.estimators import RandomForestClassifier

# Data loading and pre-processing
import tflearn.datasets.mnist as mnist
X, Y, testX, testY = mnist.load_data(one_hot=False)

m = RandomForestClassifier(n_estimators=100, max_nodes=1000)
m.fit(X, Y, batch_size=10000, display_step=10)

print("Compute the accuracy on train set:")
print(m.evaluate(X, Y, tflearn.accuracy_op))

print("Compute the accuracy on test set:")
print(m.evaluate(testX, testY, tflearn.accuracy_op))

print("Digits for test images id 0 to 5:")
print(m.predict(testX[:5]))
print("True digits:")
print(testY[:5])
4 changes: 2 additions & 2 deletions examples/basics/use_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# Load CIFAR-10 Dataset
from tflearn.datasets import cifar10
(X, Y), (X_test, Y_test) = cifar10.load_data()
Y = to_categorical(Y, 10)
Y_test = to_categorical(Y_test, 10)
Y = to_categorical(Y)
Y_test = to_categorical(Y_test)

# Create DASK array using numpy arrays
# (Note that it can work with HDF5 Dataset too)
Expand Down
4 changes: 2 additions & 2 deletions examples/basics/use_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# CIFAR-10 Dataset
from tflearn.datasets import cifar10
(X, Y), (X_test, Y_test) = cifar10.load_data()
Y = to_categorical(Y, 10)
Y_test = to_categorical(Y_test, 10)
Y = to_categorical(Y)
Y_test = to_categorical(Y_test)

# Create a hdf5 dataset from CIFAR-10 numpy array
import h5py
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/weights_loading_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import re
import tflearn
import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn.datasets.mnist as mnist

from tflearn.layers.core import input_data, dropout, fully_connected
Expand Down
2 changes: 1 addition & 1 deletion examples/extending_tensorflow/builtin_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Tensorflow graph.
"""

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn

# ----------------------------------
Expand Down
14 changes: 7 additions & 7 deletions examples/extending_tensorflow/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from __future__ import print_function

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn

# --------------------------------------
Expand Down Expand Up @@ -39,25 +39,25 @@
net = tflearn.fully_connected(net, 10, activation='linear')

# Defining other ops using Tensorflow
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(net, Y))
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(logits=net, labels=Y))
optimizer = tf.train.AdamOptimizer(learning_rate=0.01).minimize(loss)

# Initializing the variables
init = tf.initialize_all_variables()
init = tf.global_variables_initializer()

# Launch the graph
with tf.Session() as sess:
sess.run(init)

batch_size = 128
for epoch in range(2): # 2 epochs
for epoch in range(2): # 2 epochs
avg_cost = 0.
total_batch = int(mnist_data.train.num_examples/batch_size)
total_batch = int(mnist_data.train.num_examples / batch_size)
for i in range(total_batch):
batch_xs, batch_ys = mnist_data.train.next_batch(batch_size)
sess.run(optimizer, feed_dict={X: batch_xs, Y: batch_ys})
cost = sess.run(loss, feed_dict={X: batch_xs, Y: batch_ys})
avg_cost += cost/total_batch
avg_cost += cost / total_batch
if i % 20 == 0:
print("Epoch:", '%03d' % (epoch+1), "Step:", '%03d' % i,
print("Epoch:", '%03d' % (epoch + 1), "Step:", '%03d' % i,
"Loss:", str(cost))
21 changes: 11 additions & 10 deletions examples/extending_tensorflow/summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

"""

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn

# Loading MNIST dataset
Expand Down Expand Up @@ -74,11 +74,13 @@ def dnn(x):
return x

net = dnn(X)
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(net, Y))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1)
accuracy = tf.reduce_mean(
tf.cast(tf.equal(tf.argmax(net, 1), tf.argmax(Y, 1)), tf.float32),
name="acc")

with tf.name_scope('Summaries'):
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=net,labels=Y))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1)
accuracy = tf.reduce_mean(
tf.cast(tf.equal(tf.argmax(net, 1), tf.argmax(Y, 1)), tf.float32),
name="acc")

# construct two varaibles to add as additional "valiation monitors"
# these varaibles are evaluated each time validation happens (eg at a snapshot)
Expand All @@ -92,11 +94,10 @@ def dnn(x):
with tf.name_scope('CustomMonitor'):
test_var = tf.reduce_sum(tf.cast(net, tf.float32), name="test_var")
test_const = tf.constant(32.0, name="custom_constant")

# Define a train op
# Define a train op
trainop = tflearn.TrainOp(loss=loss, optimizer=optimizer,
validation_monitors=[test_var, test_const],
metric=accuracy, batch_size=128)
validation_monitors=[test_var, test_const],
metric=accuracy, batch_size=128)

# Tensorboard logs stored in /tmp/tflearn_logs/. Using verbose level 2.
trainer = tflearn.Trainer(train_ops=trainop,
Expand Down
2 changes: 1 addition & 1 deletion examples/extending_tensorflow/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TFLearn wrappers regular Tensorflow expressions.
"""

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn

# ----------------------------
Expand Down
5 changes: 3 additions & 2 deletions examples/extending_tensorflow/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
variables.
"""

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tflearn
import tflearn.variables as va

Expand Down Expand Up @@ -48,7 +48,8 @@ def dnn(x):
return x

net = dnn(X)
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(net, Y))
loss = tf.reduce_mean(
tf.nn.softmax_cross_entropy_with_logits(logits=net, labels=Y))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1)
accuracy = tf.reduce_mean(
tf.cast(tf.equal(tf.argmax(net, 1), tf.argmax(Y, 1)), tf.float32),
Expand Down