Giter Club home page Giter Club logo

tensorflow-without-a-phd's Introduction

Featured code sample

tensorflow-planespotting
Code from the Google Cloud NEXT 2018 session "Tensorflow, deep learning and modern convnets, without a PhD". Other samples from the "Tensorflow without a PhD" series are in this repository too.
Tensorflow, deep
        learning and modern convnets, without a PhD

Tensorflow and deep learning without a PhD series by @martin_gorner.

A crash course in six episodes for software developers who want to learn machine learning, with examples, theoretical concepts, and engineering tips, tricks and best practices to build and train the neural networks that solve your problems.

Tensorflow and deep learning without a PhD

The basics of building neural networks for software engineers. Neural weights and biases, activation functions, supervised learning and gradient descent. Tips and best practices for efficient training: learning rate decay, dropout regularisation and the intricacies of overfitting. Dense and convolutional neural networks. This session starts with low-level Tensorflow and also has a sample of high-level Tensorflow code using layers and Datasets. Code sample: MNIST handwritten digit recognition with 99% accuracy. Duration: 55 min

What is batch normalisation, how to use it appropriately and how to see if it is working or not. Code sample: MNIST handwritten digit recognition with 99.5% accuracy. Duration: 25 min

The superpower: batch normalization
Tensorflow, deep learning and recurrent neural networks, without a PhD

RNN basics: the RNN cell as a state machine, training and unrolling (backpropagation through time). More complex RNN cells: LSTM and GRU cells. Application to language modeling and generation. Tensorflow APIs for RNNs. Code sample: RNN-generated Shakespeare play. Duration: 55 min

Convolutional neural network architectures for image processing. Convnet basics, convolution filters and how to stack them. Learnings from the Inception model: modules with parallel convolutions, 1x1 convolutions. A simple modern convnet architecture: Squeezenet. Convenets for detection: the YOLO (You Look Only Once) architecture. Full-scale model training and serving with Tensorflow's Estimator API on Google Cloud ML Engine and Cloud TPUs (Tensor Processing Units). Application: airplane detection in aerial imagery. Duration: 55 min

Tensorflow, deep learning and modern convnets, without a PhD
Tensorflow, deep learning and modern RNN architectures, without a PhD

Advanced RNN architectures for natural language processing. Word embeddings, text classification, bidirectional models, sequence to sequence models for translation. Attention mechanisms. This session also explores Tensorflow's powerful seq2seq API. Applications: toxic comment detection and langauge translation. Co-author: Nithum Thain. Duration: 55 min

A neural network trained to play the game of Pong from just the pixels of the game. Uses reinforcement learning and policy gradients. The approach can be generalized to other problems involving a non-differentiable step that cannot be trained using traditional supervised learning techniques. A practical application: neural architecture search - neural networks designing neural networks. Co-author: Yu-Han Liu. Duration: 40 min

Tensorflow and deep reinforcement learning, without a PhD



Quick access to all code samples:
tensorflow-mnist-tutorial
dense and convolutional neural network tutorial
tensorflow-rnn-tutorial
recurrent neural network tutorial using temperature series
tensorflow-rl-pong
"pong" with reinforcement learning
tensorflow-planespotting
airplane detection model
conversationai: attention-tutorial
Toxic comment detection with RNNs and attention



*Disclaimer: This is not an official Google product but sample code provided for an educational purpose*

tensorflow-without-a-phd's People

Contributors

dhodun avatar dizcology avatar julesjulian avatar marcopegoraro avatar martin-gorner avatar meain avatar nielsswinkels avatar nioperas06 avatar quarkw avatar saip009 avatar yufengg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow-without-a-phd's Issues

doubt and update

Hi,

why in the mnist_4.2_batchnorm_convolutional.py file the biases are defined as constants? They are defined like this: B5 = tf.Variable(tf.constant(0.1, tf.float32, [10])) instead of the usual tf.Variable(tf.ones([10])/10).

And also, I refactored all your mnist training to tensorflow estimator format, you can find it here: https://github.com/ricoms/tensorflow-without-a-phd
If you want I can create a pull request, although I deleted some of your files for visualization. For visualization, I am using a google Colaboratory ipynb that creates a tensorboard temporary url.

Another point is: my mnist_4.2_batchnorm_convolutional.py did not reach 99,5% accuracy. It's still below the mnist_3.2 results:

screenshot from 2018-10-10 08-33-22

And I wonder if that is related to my first question, or my use of tf.layers.batch_normalization instead of your hardcoded function.

I intend to use it for a workshop at my college if it's ok with you. I will reference your work, of course.
@martin-gorner and team, thanks for all the great material and tutorial videos! I'm a fan.

Problem in understanding coode

In model.py in line 203 you have used tf.cast(tf.argmax(box_c, axis=-1), dtype=tf.float32) function which will return a tensor of shape (batch_n, grid_nn, grid_nn, cell_n) in which the values will be either 0.0 or 1.0, then why you have used DETECTION_THRESHOLD in line 205 because the values are either 0.0 or 1.0

box_c_sim = tf.cast(tf.argmax(box_c, axis=-1), dtype=tf.float32)
DETECTION_TRESHOLD = 0.5 # plane "detected" if predicted C>0.5
detected_w = tf.where(tf.greater(box_c_sim, DETECTION_TRESHOLD), box_w, tf.zeros_like(box_w))

AttributeError: 'Legend' object has no attribute 'draggable'

Hi,
first let me say thanks a lot for your videos, making it easier to bring deep learning to my colleagues. But if I run the demo code I get AttributeError: 'Legend' object has no attribute 'draggable' in /tensorflowvisu.py", line 192, in init
legend.draggable(True)

I get this on Mac OS with Python 3.7 and on Linux with Python 3.7

But commenting it out both times everything works fine on Mac OS - on Linux Ubuntu I get max test accurancy:0 and no training

Kind regards,

Dirk

Still issues with Tensorflow version

Hi Martin
Thanks for your comments. And sorry to bother you again as a completely beginner in programming.

Well, the thing is, Codelabs says it will soon update Tensorflow version to 2.x...

I am wondering it might be worth to update the code to fit the v.2.0. because the tutorial is very very valuable! If we as beginners can be free of code issues like version, a big progress will be made in one day. In the time of tensorflow 2.x, we still need this valuable tutorial, and it can continue its value that none can replace.

I hope it would not take much time. I even spot some version bugs and updated them though I got stuck with some another errors overnight, like -- invalid Object....

I mean I tried to do it myself, but failed it when it came with some difficult coding. Like this:
In file mnistdata.py, I updated it to the followings as suggested from https://www.tensorflow.org/guide/migrate
import tensorflow.compat.v1 as tf tf.disable_v2_behavior()

But it turned out an another issue not related to version: invalid Object....

Anyway, many thanks.

Crossentropy calculation in mnist-1.0-softmax outputs NaNs

I'm running the code in Colab, using the provided ./sample_data/mnist_train_small.csv (can't seem to import mnistdata). I'm not sure whether the mnistdata copy of the data set is normalized differently that the one provided in Colab, but I assume they're similar.

When training the model, the example's cross_entropy calculation outputs NaNs, as is documented in (this StackOverflow solution)[https://stackoverflow.com/a/33644778]. A followup (answer by colah)[https://stackoverflow.com/a/33645235] suggests that this is a deliberate choice aimed at getting users to interact with the code, but it's dated 2015, and the implementation mentioned is different than that of the latest version of mnist-1.0-softmax.py.

Anaconda install link in INSTALL.txt broken

Hello! Thanks a lot for helping me learn something new!

I'm just starting out following this tutorial. However, when I went to download anaconda, the following link that was provided in INSTALL.txt seems to be broken:
https://www.continuum.io/downloads#windows

I could access https://www.continuum.io perfectly, but the other link gave me this screen after a long load:

image

I just used https://www.anaconda.com/distribution/ instead since I presume this should work all the same.

preprocess data

I have to preprocess images that have multi label.
In particular I have to project a neural network that not only classifies two different shape, triangle or circle, but also get their dimensions: the side, the radius etc.. It's seems with no sense, but for my application it has. Where can I find a similar example?

Better explanation of how running job on GCP (Google Cloud Platform)

Greetings folks, I've a small suggestion to improve the explanations about running a model on the Google Cloud Platform, (section Run training job in the README.md) for the newbies. Do whatever you want with it...

In order to submit the training job to the Google Cloud Machine Learning Engine from your laptop:

  1. Install the GitHub tensorflow-rl-pong code and requirements on your laptop
  2. Get a Google Cloud Account and enable billing (credit card)
  3. Create a Google Cloud Platform project on Google Cloud
  4. Install the GCP command line tools on your laptop
  5. Create a Google Cloud Data bucket in order to store the code and the trained model on Google Cloud
  6. On your laptop, you should edit the submit.sh and change the commented line
    # GCS_BUCKET="gs://my-bucket/"
    and replace my-bucket by your bucket id you've created in 5)
  7. On your laptop, do bash submit.sh or eventually sudo bash submit.sh

AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

when I run mnist_1.0_softmax.py in annconda cmd with python 3.6 on win10, it reported errors, who can help me with it? many thanks.
I type the followings:
(base) F:\tensorflow-without-a-phd\tensorflow-mnist-tutorial>python mnist_1.0_softmax.py

then it reported:
Traceback (most recent call last): File "mnist_1.0_softmax.py", line 17, in <module> import tensorflowvisu File "F:\tensorflow-without-a-phd\tensorflow-mnist-tutorial\tensorflowvisu.py", line 27, in <module> tf.set_random_seed(0) AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

pong doesn't train on a desktop

The pong doesn't train on my desktop with gtx 1080.
The changes I made were,, the memory size was reduced to 80k from 100k and batch size is set to 128.
Would this be expected?

unable to train VGG16

train_path='train'
valid_path='valid'
test_path='test'
#batches for train, valid and test set
train_batches=ImageDataGenerator(rescale =
1./255).flow_from_directory(train_path,target_size=(224,224),classes=
['dog','cat'], batch_size=10)
valid_batches=ImageDataGenerator(rescale =
1./255).flow_from_directory(valid_path,target_size=(224,224),classes=
['dog','cat'], batch_size=10)
test_batches=ImageDataGenerator(rescale =
1./255).flow_from_directory(test_path,target_size=(224,224),classes=
['dog','cat'], batch_size=10)
#build CNN
input_shape = (224, 224, 3)

model=Sequential()
model.add(Conv2D(64, (3, 3), input_shape=(224,224,3),
activation='relu',padding='same'))
model.add(Conv2D(64, (3, 3),activation='relu',padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(128, (3, 3),activation='relu',padding='same'))
model.add(Conv2D(128, (3, 3),activation='relu',padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(256, (3, 3),activation='relu',padding='same'))
model.add(Conv2D(256, (3, 3),activation='relu',padding='same'))
model.add(Conv2D(256, (3, 3),activation='relu',padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(512, (3, 3),activation='relu',padding='same'))
model.add(Conv2D(512, (3, 3),activation='relu',padding='same'))
model.add(Conv2D(512, (3, 3),activation='relu',padding='same'))
model.add(Flatten())
model.add(Dense(4096, activation='relu'))
model.add(Dense(4096, activation='relu'))

model.add(Dense(2,activation='softmax'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=
['accuracy'])

model.fit_generator(train_batches,steps_per_epoch=3,validation_data=valid_batches,validation_steps=3, epochs=5,verbose=2)
The code above is VGG16 model that classifies cats and dogs, but when I train the network I still get accuracy 0.5, why?

106s - loss: 3.9315 - acc: 0.4333 - val_loss: 8.0151 - val_acc: 0.5000
I've already used the pretrained model and it worked, but now it doesn't work

Package Versions

I watched the Youtube presentation and decided to try the Pong example. However I am having issues with version incompatibility between tensorflow and numpy (I think). Can you please provide a list of package versions that I can use to get this working. Also which version of Python should I use?

Would like to also try other Atari games like Spaceinvaders

Thank you for your great video's, insights, codes, etc Much appreciated and inspiring.
After Pong want to try other Atari games like Spaceinvaders, Pacman, etc and explore the boundaries of the policy gradient approach. Unfortunately got error when I simply replaced inner_env = gym.make('Pong-v0') to inner_env = gym.make('SpaceInvaders-v0'). Saw the code was quite resilient to capture any Atari game and the training also started but gave an error in "writing summary". Any pointers what might have caused it?

`args: {'n_epoch': 6000, 'batch_size': 10000, 'output_dir': '/tmp/pong_output', 'job_dir': '/tmp/pong_output', 'restore': False, 'render': False, 'save_checkpoint_steps': 1, 'learning_rate': 0.005, 'decay': 0.99, 'gamma': 0.99, 'laziness': 0.01, 'hidden_dim': 200, 'max_to_keep': 6000}

epoch 1
Rollout phase
D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py:217: RuntimeWarning: invalid value encountered in true_divide
prwd /= np.std(prwd)
Train phase
rollout reward: -4.323713773987632
Writing summary
Traceback (most recent call last):

File "", line 1, in
runfile('D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py', wdir='D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer')

File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)

File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py", line 316, in
main(args)

File "D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py", line 249, in main
summary = sess.run(merged, feed_dict=feed_dict)

File "D:\anaconda\lib\site-packages\tensorflow\python\client\session.py", line 877, in run
run_metadata_ptr)

File "D:\anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run
feed_dict_tensor, options, run_metadata)

File "D:\anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1272, in _do_run
run_metadata)

File "D:\anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1291, in _do_call
raise type(e)(node_def, op, message)

InvalidArgumentError: Nan in summary histogram for: summaries/train/model/dense_2/kernel
[[Node: summaries/train/model/dense_2/kernel = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](summaries/train/model/dense_2/kernel/tag, summaries/train/model/dense_2/kernel/ReadVariableOp)]]

Caused by op 'summaries/train/model/dense_2/kernel', defined at:
File "D:\anaconda\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "D:\anaconda\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\anaconda\lib\site-packages\spyder_kernels\console_main
.py", line 11, in
start.main()
File "D:\anaconda\lib\site-packages\spyder_kernels\console\start.py", line 296, in main
kernel.start()
File "D:\anaconda\lib\site-packages\ipykernel\kernelapp.py", line 486, in start
self.io_loop.start()
File "D:\anaconda\lib\site-packages\tornado\platform\asyncio.py", line 127, in start
self.asyncio_loop.run_forever()
File "D:\anaconda\lib\asyncio\base_events.py", line 422, in run_forever
self._run_once()
File "D:\anaconda\lib\asyncio\base_events.py", line 1434, in _run_once
handle._run()
File "D:\anaconda\lib\asyncio\events.py", line 145, in _run
self._callback(*self._args)
File "D:\anaconda\lib\site-packages\tornado\platform\asyncio.py", line 117, in _handle_events
handler_func(fileobj, events)
File "D:\anaconda\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "D:\anaconda\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "D:\anaconda\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "D:\anaconda\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "D:\anaconda\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "D:\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "D:\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell
handler(stream, idents, msg)
File "D:\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "D:\anaconda\lib\site-packages\ipykernel\ipkernel.py", line 208, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "D:\anaconda\lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2662, in run_cell
raw_cell, store_history, silent, shell_futures)
File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2785, in _run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2907, in run_ast_nodes
if self.run_code(code, result):
File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
runfile('D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py', wdir='D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer')
File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py", line 316, in
main(args)
File "D:/OneDrive/Robotics/AINN/pong_google_cloud/tensorflow-without-a-phd/tensorflow-rl-spaceinvaders/trainer/task.py", line 148, in main
tf.summary.histogram(var.op.name, var)
File "D:\anaconda\lib\site-packages\tensorflow\python\summary\summary.py", line 187, in histogram
tag=tag, values=values, name=scope)
File "D:\anaconda\lib\site-packages\tensorflow\python\ops\gen_logging_ops.py", line 282, in histogram_summary
"HistogramSummary", tag=tag, values=values, name=name)
File "D:\anaconda\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "D:\anaconda\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "D:\anaconda\lib\site-packages\tensorflow\python\framework\ops.py", line 3155, in create_op
op_def=op_def)
File "D:\anaconda\lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Nan in summary histogram for: summaries/train/model/dense_2/kernel
[[Node: summaries/train/model/dense_2/kernel = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](summaries/train/model/dense_2/kernel/tag, summaries/train/model/dense_2/kernel/ReadVariableOp)]]`

It is running on Anaconda on a Windows machine. Thank you.

pong: on rare cases game play stops before 21 points

Running from checkpoint:
python -m trainer.task --render --restore --output-dir ./demo-checkpoint

See screenshot. Gameplay is paused at 18-18, waiting for keyboard input.
screen shot 2018-05-17 at 11 32 07
If you hit enter, gameplay restarts from 0-0.
This happens in one in eight games approximately.

UI Authentication error

Authorization Error
Error 400: redirect_uri_mismatch

You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy.

If you're the app developer, register the JavaScript origin in the Google Cloud Console.

Any guidance on how to do this?

--job-dir error

Hi
When I tried training in cloud using this link https://github.com/GoogleCloudPlatform/tensorflow-without-a-phd/tree/master/tensorflow-mnist-tutorial/mlengine

I got error Error when submitting the job (gcloud.ml-engine.jobs.submit.training) argument --job-dir: Must be of form gs://bucket/object

I specified the bucket storage here but still got an error.
gcloud ml-engine jobs submit training jobXXX --job-dir gs:///jobs/jobXXX --project --config config.yaml --module-name trainer.task --package-path trainer --runtime-version 1.4

Kindly help..thanks

TPU-optimized pipeline

Hi!
I compared Keras fit time for dataset and experimental_distribute_dataset from your great notebook using latest TF version. It turned out that distributed dataset adds no speedup. Are you sure that your distributed input pipeline is well optimized for TPU? Why don't you use other optimizations like these:

def input_fn(batch_size):
    """> 2000 images/sec"""
    files = tf.data.Dataset.list_files(FLAGS.data_dir)

    def tftecord_dataset(filename):
        buffer_size = 8 * 1024 * 1024   # 8 MiB per file
        return tf.data.TFRecordDataset(filename, buffer_size=buffer_size)

    dataset = files.apply(tf.contrib.data.parallel_interleave(
        tftecord_dataset, cycle_length=32, sloppy=True))
    dataset = dataset.apply(tf.contrib.data.shuffle_and_repeat(10000, NUM_EPOCHS))
    dataset = dataset.apply(tf.contrib.data.map_and_batch(
        parser_fn, batch_size, num_parallel_calls=4))
    return dataset.prefetch(4)

if FLAGS.use_tpu:
    # When using TPU, wrap the optimizer with CrossShardOptimizer which
    # handles synchronizarion details between different TPU cores.
    optimizer = tpu_optimizer.CrossShardOptimizer(optimizer)

Cannot feed value of shape (784,) for Tensor 'input:0', which has shape '(?, 784)

I am trying to run the MNIST code without any error from the below code ( segment 1) , however at the time of restoring the model which is in segment 2 below , i am getting the error as : Cannot feed value of shape (784,) for Tensor 'input:0', which has shape '(?, 784) , kindly suggest

segment 1

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
from random import randint
import numpy as np

logs_path = 'log_mnist_softmax'
batch_size = 100
learning_rate = 0.5
training_epochs = 10
mnist = input_data.read_data_sets("data", one_hot=True)

X = tf.placeholder(tf.float32, [None, 784], name = "input")
Y_ = tf.placeholder(tf.float32, [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
XX = tf.reshape(X, [-1, 784])

Y = tf.matmul(X, W) + b
cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=Y_, logits=Y), name = "output")
correct_prediction = tf.equal(tf.argmax(Y, 1), tf.argmax(Y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

train_step = tf.train.GradientDescentOptimizer(0.005).minimize(cross_entropy)

tf.summary.scalar("cost", cross_entropy)
tf.summary.scalar("accuracy", accuracy)
summary_op = tf.summary.merge_all()

with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
writer = tf.summary.FileWriter(logs_path,
graph=tf.get_default_graph())
for epoch in range(training_epochs):
batch_count = int(mnist.train.num_examples / batch_size)
for i in range(batch_count):
batch_x, batch_y = mnist.train.next_batch(batch_size)
, summary = sess.run([train_step, summary_op],
feed_dict={X: batch_x,
Y
: batch_y})
writer.add_summary(summary, epoch * batch_count + i)
print("Epoch: ", epoch)

print("Accuracy: ", accuracy.eval(feed_dict={X: mnist.test.images, Y_: mnist.test.labels}))
print("done")

num = randint(0, mnist.test.images.shape[0])
img = mnist.test.images[num]

classification = sess.run(tf.argmax(Y, 1), feed_dict={X: [img]})
print('Neural Network predicted', classification[0])
print('Real label is:', np.argmax(mnist.test.labels[num]))

saver = tf.train.Saver()
save_path = saver.save(sess, "data/saved_mnist_cnn.ckpt")
print("Model saved to %s" % save_path)

Segment 2

import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets('data', one_hot=True)
sess = tf.InteractiveSession()
new_saver = tf.train.import_meta_graph('data\saved_mnist_cnn.ckpt.meta')
new_saver.restore(sess, 'data\saved_mnist_cnn.ckpt')
tf.get_default_graph().as_graph_def()

x = sess.graph.get_tensor_by_name("input:0")

y_conv = sess.graph.get_tensor_by_name("output:0")
image_b = mnist.test.images[100]
result = sess.run(y_conv, feed_dict={x:image_b})
print(result)
print(sess.run(tf.argmax(result, 1)))

plt.imshow(image_b.reshape([28, 28]), cmap='Greys')
plt.show()

NotFoundError while running the game.

Hi
I am relatively a new tf user. I use anaconda 3.5 in windows10. I have installed my tensorflow in a virtual environment.
I have run some other RL projects with my tensorflow. But this project gives the error below now;

`(tensorflow) C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong>python -m trainer.task --render --restore --output-dir ./demo-checkpoint
args: {'laziness': 0.01, 'learning_rate': 0.005, 'save_checkpoint_steps': 1, 'n_epoch': 6000, 'max_to_keep': 6000, 'restore': True, 'job_dir': '/tmp/pong_output', 'hidden_dim': 200, 'output_dir': './demo-checkpoint', 'gamma': 0.99, 'decay': 0.99, 'render': True, 'batch_size': 10000}
2018-09-18 09:54:26.123793: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Restoring from ./demo-checkpoint\model.ckpt-6000
2018-09-18 09:54:26.168774: W T:\src\github\tensorflow\tensorflow\core\framework\op_kernel.cc:1275] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key rollout/model/dense/kernel not found in checkpoint




Traceback (most recent call last):
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1278, in _do_call
    return fn(*args)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1263, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1350, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.NotFoundError: Key rollout/model/dense/kernel not found in checkpoint
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1725, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 877, in run
    run_metadata_ptr)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run
    feed_dict_tensor, options, run_metadata)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1272, in _do_run
    run_metadata)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1291, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key rollout/model/dense/kernel not found in checkpoint
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

Caused by op 'save/RestoreV2', defined at:
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 293, in <module>
    main(args)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 110, in main
    saver = tf.train.Saver(max_to_keep=args.max_to_keep)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1281, in __init__
    self.build()
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1293, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1330, in _build
    build_save=build_save, build_restore=build_restore)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 778, in _build_internal
    restore_sequentially, reshape)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 397, in _AddRestoreOps
    restore_sequentially)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 829, in bulk_restore
    return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1546, in restore_v2
    shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3155, in create_op
    op_def=op_def)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in __init__
    self._traceback = tf_stack.extract_stack()

NotFoundError (see above for traceback): Key rollout/model/dense/kernel not found in checkpoint
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1737, in restore
    checkpointable.OBJECT_GRAPH_PROTO_KEY)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 348, in get_tensor
    status)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 519, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Key _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 293, in <module>
    main(args)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 145, in main
    saver.restore(sess, restore_path)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1743, in restore
    err, "a Variable name or other graph key that is missing")
tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key rollout/model/dense/kernel not found in checkpoint
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

Caused by op 'save/RestoreV2', defined at:
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 293, in <module>
    main(args)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\models\tensorflow-rl-pong\trainer\task.py", line 110, in main
    saver = tf.train.Saver(max_to_keep=args.max_to_keep)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1281, in __init__
    self.build()
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1293, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1330, in _build
    build_save=build_save, build_restore=build_restore)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 778, in _build_internal
    restore_sequentially, reshape)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 397, in _AddRestoreOps
    restore_sequentially)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 829, in bulk_restore
    return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1546, in restore_v2
    shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3155, in create_op
    op_def=op_def)
  File "C:\Users\KOCAKMA\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in __init__
    self._traceback = tf_stack.extract_stack()



NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key rollout/model/dense/kernel not found in checkpoint
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
`

-I have uninstalled tf and reinstalled. The error continues.
-I have used the absolute path as --output-dir . The error continues

Note: The code was successfully running before I changed my windows 10 PATH to make anaconda python default. After this change, my tensorflow stopped working in root. So I created a conda virtual environment and reinstalled it, other projects are working fine in new environment. For pong project the error above came up.

where is mlengine/trainer/task.py

High-level Tensorflow (tf.layers)
This version is is for models built using the tf.layers high-level API and wrapped in a tf.estimator.Estimator interface.

def model_fn(features, labels, mode):
# ... neural network layers ...
logits = tf.layers.dense(Y4, 200, use_bias=False)
bn = tf.layers.batch_normalization(logits,
axis=1,
center=True,
scale=False,
training=(mode == tf.estimator.ModeKeys.TRAIN))
Y5 = tf.nn.relu(bn)
# ... more neural network layers ...
A complete sample is available in mlengine/trainer/task.py

mlengine/trainer/task.py theweb link is 404

Problem with shareable variables. with tf.variable_scope('model', reuse=tf.AUTO_REUSE)

In my network rollout of next epoch dosen't use trained weights of prev train operation. And I see in tensorboard that rollout and train graph have seperate 'model' and layers with different names (for ex. dense_1, dense_0, dense_2, dence_3).

Where is a problem?
I slightly changed code:

`

def build_graph(observations):

with tf.variable_scope('model', reuse=tf.AUTO_REUSE) as model:
    
    
    lstm=tf.keras.layers.LSTM(100, return_sequences=True, stateful=False, use_bias=True)(observations)
    lstm2=tf.keras.layers.LSTM(64, return_sequences=True, stateful=False, use_bias=True, dropout=0.2)(lstm)
    lstm3=tf.keras.layers.LSTM(64, return_sequences=True, stateful=False, use_bias=True)(lstm2)
    lstm7=tf.keras.layers.LSTM(32, stateful=False, use_bias=True, dropout=0.2)(lstm3)
    #hidden = tf.keras.layers.Dense(50, use_bias=True, activation='relu')(lstm2)
    logits = tf.keras.layers.Dense(len(ACTIONS), 
                                   #bias_initializer=tf.constant_initializer(value=[7.,0.1,0.1]), 
                                   use_bias=True)(lstm7)

    
     
    
return logits 

def main(args):
    args_dict = vars(args)
    print('args: {}'.format(args_dict))

    with tf.Graph().as_default() as g:
        # rollout subgraph

        with tf.device('/cpu:0'):
            with tf.name_scope('rollout'):

                observations = tf.placeholder(shape=(args.batch_size, args.sequence_size, OBSERVATION_DIM), dtype=tf.float32)

                logits = build_graph(observations)


                logits_for_sampling = tf.reshape(logits, shape=(args.batch_size, len(ACTIONS)))


                # Sample the action to be played during rollout.

                sample_action = tf.squeeze(tf.multinomial(logits=logits_for_sampling, num_samples=1))

            optimizer = tf.train.RMSPropOptimizer(
                learning_rate=args.learning_rate,
                decay=args.decay
            )

        # dataset subgraph for experience replay
        with tf.name_scope('dataset'):
            # the dataset reads from MEMORY

            ds = tf.data.Dataset.from_generator(gen, output_types=(tf.float32, tf.int64, tf.float32))
            iterator = ds.make_one_shot_iterator()

        # training subgraph
        with tf.name_scope('train'):
            # the train_op includes getting a batch of data from the dataset, so we do not need to use a feed_dict when running the train_op.
            next_batch = iterator.get_next()

            global episode
            train_observations, labels, processed_rewards = next_batch
            episode=next_batch

            # This reuses the same weights in the rollout phase.
            train_observations.set_shape((args.batch_size, args.sequence_size, OBSERVATION_DIM))
            train_logits = build_graph(train_observations)

            cross_entropies = tf.nn.sparse_softmax_cross_entropy_with_logits(
                logits=train_logits,
                labels=labels
            )



            loss = tf.reduce_sum(processed_rewards * cross_entropies)

            global_step = tf.train.get_or_create_global_step()

            train_op = optimizer.minimize(loss, global_step=global_step)

        init = tf.global_variables_initializer()
        saver = tf.train.Saver(max_to_keep=args.max_to_keep)

`

Not able to play imported pong models trained on Google Cloud Platform...

Great tutorial and video!

I've trained a model on GCP (Google Cloud Platform) and I've dowloaded a 1000 epochs checkpoint from GCP on my laptop in a demo-checkpoint-1000-epochs folder, in order to check the progression.

Then, I've tried to run the 1000 epochs model using the command: python3 -m trainer.task --render --restore --output-dir ./demo-checkpoint-1000-epochs replacing the 6000 epochs files by those ones: model.ckpt-1000.data-00000-of-00001, model.ckpt-1000.index, model.ckpt-1000.meta and I've got a ValueError: Can't load save_path when it is None.

Can I run a planespotting model locally?

I'm new in tensorflow. I have only small keras experiences, so I don't know about tensorflow itself well...

I'm trying to train and learn a tensorflow planespotting model locally. Training is done by reading the readme file. I get saved_model.pb file and variables as result. But I got stuck on inference.

import tensorflow as tf
import numpy as np

# DATA
DATA = './samples/airplane_sample.png'

# MODEL
SAVED_MODEL_DIR = './1559196417/'

def decode_image():
    img_bytes = tf.read_file(DATA)
    decoded = tf.image.decode_image(img_bytes, channels=3)
    return tf.cast(decoded, dtype=tf.uint8)

def main1():
    with tf.Session(graph=tf.Graph()) as sess:
        tf.saved_model.loader.load(sess, [tf.saved_model.tag_constants.SERVING], SAVED_MODEL_DIR)
        img = decode_image()
        result = sess.run(['classes'], feed_dict={'input': img})
        print(result)

def main2():
    model = tf.contrib.predictor.from_saved_model(SAVED_MODEL_DIR)
    pred = model({'image_bytes': [decode_image()], 'square_size': [tf.placeholder(tf.int32)]})
    print(pred)

if __name__ == "__main__":
    main2()

Above is a code written by me but it doesn't work. Could you give me some advice to me?

PLOT function does not work

The datavis.animate can only plot the startup figure even the iterations are set to 2001 or 10001.
And the output in the terminal says: max test accuracy: 0
the model has not been trained at all.

while the following code can output the normal value

for i in range(10000+1): training_step(i, i % 100 == 0, i % 20 == 0)

how to modify "tf_dataset.make_one_shot_iterator().get_next()"

in mnistdata.py, I met a similar issue related to tensorflow version. but I do not know how to modify it.

as this link suggested, I got 'tf_dataset.make_one_shot_iterator()' to 'tf_dataset.compat.v1.data.make_one_shot_iterator'. But unfortunately it did not work!
it reported:
AttributeError: 'RepeatDataset' object has no attribute 'compat'

anyone can kindly help me with it.

Not able to monitor the progress of training, using TensorBoard on GCP

I'm trying to monitor the progress of training, using TensorBoard on GCP... (It's my first time with GCP, but I've used AppEngine long time ago...)

  1. I go into the ML Engine Jobs view and activate a Google Cloud Shell
  2. In the Cloud Shell I type the command:
    tensorboard --logdir gs://exercices-tensorflow/pong_20180708_033245 --port 8080
  3. I open a Web Preview (preview on port 8080)

I've got a TensorBoard page but it's inactive... with the message «No dashboards are active for the current data set.» See below screenshot...

capture d ecran 2018-07-08 a 15 48 57

The link with the training data seems not to be done ????
What is the events file? And how to set it?

NameError: name 'raw_input' is not defined

After the end of the 1st epoch:

>>>>>>> epoch 1
>>> Rollout phase
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pawel/M/outrun/tensorflow-without-a-phd/tensorflow-rl-pong/trainer/task.py", line 292, in <module>
    main(args)
  File "/home/pawel/M/outrun/tensorflow-without-a-phd/tensorflow-rl-pong/trainer/task.py", line 204, in main
    _ = raw_input('episode done, press Enter to replay')
NameError: name 'raw_input' is not defined

raw_input() is not supported in Python 3.

As per Guido's explanation:
https://docs.python.org/3/whatsnew/3.0.html
https://www.python.org/dev/peps/pep-3111/

raw_input() was renamed to input()

periph_rois

Can you please explain the code for periph_rois ,I mean what it is for? and I am not able to understand the significance of 'expand' variable in traineryolo/box_utils.py

02_RNN_generator_temperatures_playground:

utils_display.picture_this_4() does not run (without any changes).

I get the below error information running jupyter on Ubuntu desktop 18.04. It is the same problem with:

utils_display.picture_this_6()

By commenting out these the notebook runs without problems.

And thanks by the way for the great videos and playgrounds, they really upgrade ones neural network understanding and learning!


AttributeError Traceback (most recent call last)
in ()
7 visu_dates = evdates[START_DATE:END_DATE]
8
----> 9 utils_display.picture_this_4(visu_temperatures, visu_dates)

~/git-public/tensorflow-without-a-phd/tensorflow-rnn-tutorial/tutorial/utils_display.py in picture_this_4(temperatures, dates)
73 if interpolated_sequence:
74 # light shade of red just for visibility
---> 75 plt.axvspan(startdate+np.timedelta64(-5, 'D'), stopdate+np.timedelta64(6, 'D'), facecolor='#FFCCCC', alpha=1)
76 # actual interpolated region
77 plt.axvspan(startdate+np.timedelta64(-1, 'D'), stopdate+np.timedelta64(1, 'D'), facecolor='#FF8888', alpha=1)

/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py in axvspan(xmin, xmax, ymin, ymax, hold, **kwargs)
2753 mplDeprecation)
2754 try:
-> 2755 ret = ax.axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs)
2756 finally:
2757 ax._hold = washold

/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_axes.py in axvspan(self, xmin, xmax, ymin, ymax, **kwargs)
904
905 # first we need to strip away the units
--> 906 xmin, xmax = self.convert_xunits([xmin, xmax])
907 ymin, ymax = self.convert_yunits([ymin, ymax])
908

/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py in convert_xunits(self, x)
189 if ax is None or ax.xaxis is None:
190 return x
--> 191 return ax.xaxis.convert_units(x)
192
193 def convert_yunits(self, y):

/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py in convert_units(self, x)
1524 return x
1525
-> 1526 ret = self.converter.convert(x, self.units, self)
1527 return ret
1528

/usr/local/lib/python3.6/dist-packages/matplotlib/dates.py in convert(value, unit, axis)
1814 The unit and axis arguments are not used.
1815 """
-> 1816 return date2num(value)
1817
1818 @staticmethod

/usr/local/lib/python3.6/dist-packages/matplotlib/dates.py in date2num(d)
450 if not d.size:
451 return d
--> 452 return _to_ordinalf_np_vectorized(d)
453
454

~/.local/lib/python3.6/site-packages/numpy/lib/function_base.py in call(self, *args, **kwargs)
2753 vargs.extend([kwargs[_n] for _n in names])
2754
-> 2755 return self._vectorize_call(func=func, args=vargs)
2756
2757 def _get_ufunc_and_otypes(self, func, args):

~/.local/lib/python3.6/site-packages/numpy/lib/function_base.py in _vectorize_call(self, func, args)
2823 res = func()
2824 else:
-> 2825 ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
2826
2827 # Convert args to object arrays first

~/.local/lib/python3.6/site-packages/numpy/lib/function_base.py in _get_ufunc_and_otypes(self, func, args)
2783
2784 inputs = [arg.flat[0] for arg in args]
-> 2785 outputs = func(*inputs)
2786
2787 # Performance note: profiling indicates that -- for simple

/usr/local/lib/python3.6/dist-packages/matplotlib/dates.py in _to_ordinalf(dt)
253 tzi = UTC
254
--> 255 base = float(dt.toordinal())
256
257 # If it's sufficiently datetime-like, it will have a date() method

AttributeError: 'numpy.datetime64' object has no attribute 'toordinal'

ConnectionResetError: [WinError 10054] An existing connection was forcibly close d by the remote host

MNIST:
Successfully downloaded and unzipped train-images-idx3-ubyte.gz 9912422 bytes.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\urllib\request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\ProgramData\Anaconda3\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\ProgramData\Anaconda3\lib\http\client.py", line 1285, in _send_reques
t
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\ProgramData\Anaconda3\lib\http\client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\ProgramData\Anaconda3\lib\http\client.py", line 1026, in _send_output

self.send(msg)

File "C:\ProgramData\Anaconda3\lib\http\client.py", line 964, in send
self.connect()
File "C:\ProgramData\Anaconda3\lib\http\client.py", line 1400, in connect
server_hostname=server_hostname)
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 814, in init
self.do_handshake()
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly close
d by the remote host

unsupervised learning

Hi,
Would you be able to show an example of deploying tensoflow for unsupervised learning?
An example would be image segmentation when there is no gold standard or labeling available.

Thanks!

X.W

Am i crazy or does the matrix multiplication in this slide not work given that the nrows = 100 and ncols = 10???
matrixMultiply.pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.