amygdala / tensorflow-workshop Goto Github PK
View Code? Open in Web Editor NEWThis repo contains materials for use in a TensorFlow workshop.
License: Apache License 2.0
This repo contains materials for use in a TensorFlow workshop.
License: Apache License 2.0
Yesterday, I saw the complete example of tf on k8s.
But now some files are missing in the branch ”tensorkubes“.
Could you send me the original complete file?
thx~
When I tried to validate the output from preprocess.py against text8 as input, I found mismatch between input word sequence and the index encoded sequence which is written to text8-train.pb2.
To reproduce, please add below two lines to preprocess.py after calling build_string_index()
print('{}'.format(words[:100]))
print('{}'.format(index[word_indices[:100]]))
Here is the output I get:
['anarchism' 'originated' 'as' 'a' 'term' 'of' 'abuse' 'first' 'used'
'against' 'early' 'working' 'class' 'radicals' 'including' 'the' 'diggers'
'of' 'the' 'english' 'revolution' 'and' 'the' 'sans' 'culottes' 'of' 'the'
'french' 'revolution' 'whilst' 'the' 'term' 'is' 'still' 'used' 'in' 'a'
'pejorative' 'way' 'to' 'describe' 'any' 'act' 'that' 'used' 'violent'
'means' 'to' 'destroy' 'the' 'organization' 'of' 'society' 'it' 'has'
'also' 'been' 'taken' 'up' 'as' 'a' 'positive' 'label' 'by' 'self'
'defined' 'anarchists' 'the' 'word' 'anarchism' 'is' 'derived' 'from'
'the' 'greek' 'without' 'archons' 'ruler' 'chief' 'king' 'anarchism' 'as'
'a' 'political' 'philosophy' 'is' 'the' 'belief' 'that' 'rulers' 'are'
'unnecessary' 'and' 'should' 'be' 'abolished' 'although' 'there' 'are'
'differing']
['instance' 'dating' 'as' 'a' 'term' 'of' 'distances' 'first' 'used'
'against' 'early' 'working' 'class' 'squid' 'including' 'the' 'hanoi' 'of'
'the' 'english' 'treaty' 'and' 'the' 'malinowski' 'UNK' 'of' 'the'
'french' 'treaty' 'afro' 'the' 'term' 'is' 'still' 'used' 'in' 'a' 'buddy'
'way' 'to' 'islam' 'any' 'act' 'that' 'used' 'zeus' 'lincoln' 'to'
'vector' 'the' 'car' 'of' 'society' 'it' 'has' 'also' 'been' 'latin' 'up'
'as' 'a' 'failed' 'eddington' 'by' 'self' 'command' 'anarchists' 'the'
'word' 'instance' 'is' 'treaty' 'from' 'the' 'born' 'without' 'mml'
'progress' 'coast' 'king' 'instance' 'as' 'a' 'political' 'culture' 'is'
'the' 'me' 'that' 'dating' 'are' 'squid' 'and' 'public' 'be' 'acceptable'
'although' 'there' 'are' 'absent']
I am getting the following error when doing prediction after deploying model in cloud
In my local
C:\Program Files (x86)\Google\Cloud SDK>gcloud ml-engine predict --model Deep_Wide --version v4 --json-instances C:\Users\vikas\PycharmProjects\TensorflowUScensusData\test.json
{
"error": "Prediction failed: Error processing input: Incompatible types: 0 vs. float64"
}
As well as if i run the same in cloud
vkg_vikas_gupta@vikas-sapref:~$ gcloud ml-engine predict --model Deep_Wide --version v5 --json-instances data/test.json
{
"error": "Prediction failed: Error processing input: Incompatible types: 0 vs. float64"
}
Hello ,
Im simply trying to test code for image recognition and my code keeps throwing exception at "var graph = new Graph().as_default();' .The error is ' System.DllNotFoundException has been thrown ."tensorflow". I have added Tensorflow.Net from NuGet and there are no compilation errors and all the references are available . Im using Xamarin ,Net Console project .
using NumSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using Tensorflow;
using Tensorflow.Contrib;
using Tensorflow.Framework;
using Tensorflow.Operations;
public static void AnalyzeImage()
{
string pb_path ="/Users/jacksparow/Desktop/images2/frozen_inference_graph.pb";
string image_path = "/Users/jacksparow/Desktop/images1/a1.jpg";
var tensor = ReadTensorFromImageFile(image_path);
graph = new Graph().as_default();
//import GraphDef from pb file
graph.Import(pb_path);
var input_name = "input";
var output_name = "output";
var input_operation = graph.OperationByName(input_name);
var output_operation = graph.OperationByName(output_name);
var idx = 0;
float propability = 0;
with(tf.Session(graph), sess =>
{
var results = sess.run(output_operation.outputs[0], new FeedItem(input_operation.outputs[0], tensor));
var probabilities = results.Data<float>();
for (int i = 0; i < probabilities.Length; i++)
{
if (probabilities[i] > propability)
{
idx = i;
propability = probabilities[i];
}
}
});
}
Ran into this error in step 5 when trying to run the distributed workbook.
NotFoundErrorTraceback (most recent call last)
in ()
52 last_report_step = step
53 average_loss_total = 0
---> 54 saver.save(session, save_dir_prefix, global_step=step)
55
56 except tf.errors.UnavailableError as e:
/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.pyc in save(self, sess, save_path, global_step, latest_filename, meta_graph_suffix, write_meta_graph)
1035 model_checkpoint_path = sess.run(
1036 self.saver_def.save_tensor_name,
-> 1037 {self.saver_def.filename_tensor_name: checkpoint_file})
1038 model_checkpoint_path = compat.as_str(model_checkpoint_path)
1039 self._MaybeDeleteOldCheckpoints(model_checkpoint_path,
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata)
338 try:
339 result = self._run(None, fetches, feed_dict, options_ptr,
--> 340 run_metadata_ptr)
341 if run_metadata:
342 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata)
562 try:
563 results = self._do_run(handle, target_list, unique_fetches,
--> 564 feed_dict_string, options, run_metadata)
565 finally:
566 # The movers are no longer used. Delete them.
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
635 if handle is None:
636 return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
--> 637 target_list, options, run_metadata)
638 else:
639 return self._do_call(_prun_fn, self._session, handle, feed_dict,
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_call(self, fn, *args)
657 # pylint: disable=protected-access
658 raise errors._make_specific_exception(node_def, op, error_message,
--> 659 e.code)
660 # pylint: enable=protected-access
661
NotFoundError: /var/log/checkpoints/word2vec/1464465701/model-67.tempstate14588595220314914492
[[Node: save/save = SaveSlices[T=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32], _device="/job:master/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/save/tensor_names, save/save/shapes_and_slices, Variable_S1165, Variable_1_S1167, Variable_2_S1169, Variable_3_S1171, Variable_4_S1173, Variable_5_S1175, Variable_6_S1177)]]
Caused by op u'save/save', defined at:
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/ipykernel/main.py", line 3, in
app.launch_new_instance()
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 596, in launch_instance
app.start()
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelapp.py", line 442, in start
ioloop.IOLoop.instance().start()
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py", line 162, in start
super(ZMQIOLoop, self).start()
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 883, in start
handler_func(fd_obj, events)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 276, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 391, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/ipkernel.py", line 199, in do_execute
shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2723, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2825, in run_ast_nodes
if self.run_code(code, result):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2885, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 56, in
saver = tf.train.Saver(tf.all_variables())
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 832, in init
restore_sequentially=restore_sequentially)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 500, in build
save_tensor = self._AddSaveOps(filename_tensor, vars_to_save)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 197, in _AddSaveOps
save = self.save_op(filename_tensor, vars_to_save)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 149, in save_op
tensor_slices=[vs.slice_spec for vs in vars_to_save])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/io_ops.py", line 172, in _save
tensors, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 341, in _save_slices
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 661, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2154, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1154, in init
self._traceback = _extract_stack()
The notebook samples jump into Google Cloud deployment. But how to do the actual predictions on local machine. Lets say i have few rows having all the FEATURE_COLUMNS and i want to give those to the trained model and let it predict the label (in our case income_bracket). A small sample will help alot
It would be nice to put the PyCon video link on the README.md
=)
Thank you for the nice introductory tensorflow talk!!
Hi,
I was trying to create wordnet using my corpus but i m not sure how to visualize it.
Can someone help me on this?
Thanks
trying to follow your readme creating a 3 node cluster with machine type n1-highmem-8
always get this error message:
EXTERNAL: Insufficient regional quota to satisfy request for resource: "CPUS". The request requires '24.0' and is short '16.0'. The regional quota is '8.0' with '8.0' available.
Is this default quota limitation for trial account?
AFAICT, gcloud beta ml local train
args have had hyphens converted to underscores, and should now be:
train_data_paths
, eval_data_paths
, and output_path
.
This is the last part of the code.
When I was running this:
try:
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=5000)
plot_only = 500
low_dim_embs = tsne.fit_transform(final_embeddings[:plot_only, :]) # <--- this line
labels = [reverse_dictionary[i] for i in xrange(plot_only)]
plot_with_labels(low_dim_embs, labels)
except ImportError:
print("Please install sklearn and matplotlib to visualize embeddings.")
It gives me the error message as follow
ValueError Traceback (most recent call last)
<ipython-input-14-6eeaf6258bde> in <module>()
5 tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=5000)
6 plot_only = 500
----> 7 low_dim_embs = tsne.fit_transform(final_embeddings[:plot_only, :])
8 labels = [reverse_dictionary[i] for i in xrange(plot_only)]
9 plot_with_labels(low_dim_embs, labels)
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/sklearn/manifold/t_sne.py in fit_transform(self, X, y)
864 Embedding of the training data in low-dimensional space.
865 """
--> 866 embedding = self._fit(X)
867 self.embedding_ = embedding
868 return self.embedding_
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/sklearn/manifold/t_sne.py in _fit(self, X, skip_num_points)
775 X_embedded=X_embedded,
776 neighbors=neighbors_nn,
--> 777 skip_num_points=skip_num_points)
778
779 def _tsne(self, P, degrees_of_freedom, n_samples, random_state,
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/sklearn/manifold/t_sne.py in _tsne(self, P, degrees_of_freedom, n_samples, random_state, X_embedded, neighbors, skip_num_points)
830 opt_args['momentum'] = 0.8
831 opt_args['it'] = it + 1
--> 832 params, error, it = _gradient_descent(obj_func, params, **opt_args)
833 if self.verbose:
834 print("[t-SNE] Error after %d iterations with early "
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/sklearn/manifold/t_sne.py in _gradient_descent(objective, p0, it, n_iter, objective_error, n_iter_check, n_iter_without_progress, momentum, learning_rate, min_gain, min_grad_norm, min_error_diff, verbose, args, kwargs)
385 for i in range(it, n_iter):
386 new_error, grad = objective(p, *args, **kwargs)
--> 387 grad_norm = linalg.norm(grad)
388
389 inc = update * grad >= 0.0
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/scipy/linalg/misc.py in norm(a, ord, axis, keepdims)
127 """
128 # Differs from numpy only in non-finite handling and the use of blas.
--> 129 a = np.asarray_chkfinite(a)
130
131 # Only use optimized norms if axis and keepdims are not specified.
/Users/lucas/anaconda/envs/tf/lib/python3.5/site-packages/numpy/lib/function_base.py in asarray_chkfinite(a, dtype, order)
1031 if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
1032 raise ValueError(
-> 1033 "array must not contain infs or NaNs")
1034 return a
1035
ValueError: array must not contain infs or NaNs
Very new to this field. How can I resolve this issue? Thank you in advance.
I added a note earlier but figured I should make it a proper issue.
Can you revisit this commit: 5393ac5#diff-300e5b2cbe160af1a9b56b074a6e6b04R144
which now works for py 3 but not py 2.7?
(whereas reverting the commit lets it work for py 2.7 but not py 3...)
It would be much better if outputs are also added with the programs or a notebook version is uploaded in TF 1.12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.