GithubHelp home page GithubHelp logo

burness / tensorflow-101 Goto Github PK

View Code? Open in Web Editor NEW
1.1K 86.0 555.0 39.99 MB

learn code with tensorflow

Python 97.54% Shell 0.29% CSS 0.04% HTML 1.18% JavaScript 0.96%
tensorflow-experiments gan infogan deeplearning flask tensorflow

tensorflow-101's Introduction

algorithm

MLP for mnist done

covert to tfrecord

test on 102flowers done command like this:

python covert_somedata_to_tfrecord.py --dataset_name=102flowers --dataset_dir='./'

serving

test on MLP model on mnist done

download the mnist jpgs on baidu yunpan mnist jpgs

Reference: https://github.com/tobegit3hub/deep_recommend_system

finetuning and deploy model with flask

In folder finetuning, we use tf.slim to finetuning the pretrain model (I use the same method in my porn detection) and use flask to buid a very simple inference system.

Inference Demo

I deploy a image classification in demo page. It is based on Tensorflow and Flask. Feel free to try.

Chinese rec

You can get the detailed introductation in TensorFlow与中文手写汉字识别

GAN

AC-GAN and Info-GAN in TensorFlow

The project in GAN includ AC-GAN and Info-GAN:

  • AC-GAN
  • Info-GAN

Result

Infogan result:

AC-GAN result:

You can get detailed information in GAN的理解与TF的实现

DeepColor

The images from safebooru.org, you can download from the baidu yunpan https://pan.baidu.com/s/1c1HOIHU.

The results:

details in CGAN之deepcolor实践

Text Classifer

You can get the detail information in 自然语言处理第一番之文本分类器. Classic methods such as Word Count Distribution and TF-IDF and DeepLearning Methods based CNN and C-LSTM are provided in nlp/text_classifier

tensorflow-101's People

Contributors

burness avatar soloice avatar titan-pycompat 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

tensorflow-101's Issues

GAN: About updating nets.

Hello, I have a question about GAN and InfoGAN.
The theory of the paper is 'updating G and D alternatively'. But in your implementation, you don't set var_list. So, when updating, the Tensorflow will always update all the parameters involved in optimization goal(the cross-entropy), which include G's and D's parameters. It is different from original method.
I want to know, is it OK to do that? Is it a bug or alternative method?
Thank you.

inference验证多张图片使用for循环会报错

修改后的代码:
for root, sub_folder, file_list in os.walk("../image/fonts/test/"):
for file_path in file_list:
image_file = root + file_path
final_predict_val, final_predict_index = inference(image_file)
错误信息:
Traceback (most recent call last):
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1039, in _do_call
return fn(*args)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1021, in _run_fn
status, run_metadata)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\contextlib.py", line 66, in exit
next(self.gen)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: Key fully_connected_19/biases/Adam not found in checkpoint
[[Node: save_1/RestoreV2_109 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_109/tensor_names, save_1/RestoreV2_109/shape_and_slices)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\pydevd.py", line 1585, in
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\pydevd.py", line 1015, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 303, in
run()
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 297, in run
final_predict_val, final_predict_index = inference(image_file)
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 209, in inference
saver.restore(sess, ckpt)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1457, in restore
{self.saver_def.filename_tensor_name: save_path})
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 778, in run
run_metadata_ptr)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key fully_connected_19/biases/Adam not found in checkpoint
[[Node: save_1/RestoreV2_109 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_109/tensor_names, save_1/RestoreV2_109/shape_and_slices)]]

Caused by op 'save_1/RestoreV2_109', defined at:
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\pydevd.py", line 1585, in
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\pydevd.py", line 1015, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 303, in
run()
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 297, in run
final_predict_val, final_predict_index = inference(image_file)
File "D:/ucmed-python/tensorflow_learning/chinese_font_flip/fonts_main.py", line 206, in inference
saver = tf.train.Saver()
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1056, in init
self.build()
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1086, in build
restore_sequentially=self._restore_sequentially)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 691, in build
restore_sequentially, reshape)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 407, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 247, in restore_op
[spec.tensor.dtype])[0])
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 669, in restore_v2
dtypes=dtypes, name=name)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
op_def=op_def)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Users\ucmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in init
self._traceback = _extract_stack()

NotFoundError (see above for traceback): Key fully_connected_19/biases/Adam not found in checkpoint
[[Node: save_1/RestoreV2_109 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_109/tensor_names, save_1/RestoreV2_109/shape_and_slices)]]

TensorFlow的问答模型

hi, 最近注意到你也开始做NLP方向的任务了,我在研究使用深度学习做QA系统。

我创建了一个问答数据集,面向垂直领域的FAQ,

https://github.com/Samurais/insuranceqa-corpus-zh

在这方面,比较缺少好的中文语料,insuranceqa-corpus-zh是基于英文语料翻译的,效果还不错,欢迎使用!

error for finetuning project when running "run.sh"

https://github.com/burness/tensorflow-101/tree/master/finetuning
Traceback (most recent call last):
File "../train_image_classifier.py", line 591, in
tf.app.run()
File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "../train_image_classifier.py", line 443, in main
train_image_size)
File "/home/jcc/tensorflow/tensorflow-101/finetuning/preprocessing/preprocessing_factory.py", line 62, in preprocessing_fn
**kwargs)
File "/home/jcc/tensorflow/tensorflow-101/finetuning/preprocessing/inception_preprocessing.py", line 308, in preprocess_image
return preprocess_for_train(image, height, width, bbox, fast_mode)
File "/home/jcc/tensorflow/tensorflow-101/finetuning/preprocessing/inception_preprocessing.py", line 198, in preprocess_for_train
tf.image_summary('image_with_bounding_boxes', image_with_box)
AttributeError: 'module' object has no attribute 'image_summary'
My tensorflow is 1.0-rc2 version. Need any change of the code?

[ontinuous factor loss]

Can you explain for me "what is continuous factor loss"? i read the paper about AC-Gan and can not find anything that related to "continuous factor loss".

Performance issue in /finetuning/convert_pys (by P3)

Hello! I've found a performance issue in /finetuning/convert_pys/covert_datasets_tfrecord.py: with tf.Session('') as sess(here) is defined in the function _convert_dataset(here) which is repeatedly called in the loop for i in range(nFold)(here).

tf.Session being defined repeatedly could lead to incremental overhead. If you define tf.Session out of the loop and pass tf.Session as a parameter to the loop, your program would be much more efficient. Here is the Stack Overflow post to support it.

Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.

关于“t_tag_infos.txt”文件

你好,首先非常感谢你知乎上对text classfier 的总结,其次想请问一下在

 tensorflow-101/nlp/text_classifier/scripts/dataset_helpers/cut_doc.py

代码中的下面一个文件我应该去哪里找啊?

WORD_DICT = "/Users/burness/git_repository/dl_opensource/nlp/oxford-cs-deepnlp-2017/practical-2/data/origin_data/t_tag_infos.txt"

TensorFlow APIs compatibility problems

Hi,

I noticed some TensorFlow API usage in your code might lead to crash on early version.
Some API appeared only in tf v1.0 like tf.global_variables_initializer, tf.local_variables_initializer, tf.summary.merge_all and so on.

I made some patches for these APIs in #21

And I noticed some issues asked about tf.concat. It's another problems I found too. The paramter sequence/name has changed since tf v1.0. If you need, I can made some patches too.

I know it's a old problem, maybe you don't want to be compatible with too old versions. But it's also a compatibility problem right? @burness @soloice

Look forward to your reply, Thanks!

step相关问题

请问为什么跑几十个step后会停止,而且有时是十几个step,有时是几十个step?

infogan code cannot generate reasonable result

Hi,

I'm running the original code you give for infogan. I used train.py to train the network first, and then used generate.py to generate sample pictures. However, the result picture does not give the expected result. Both sample.png and fake.png are all pictures of number 1, which shows that the categorical latent code doesn't work. Also, for the two continuous latent code, they don't give very intuitive meaning, but rather like random noise.

I noticed that during training, the generation loss remains pretty large even at the end of 50 training epochs. It's like this:
cur epoch 50 update l_d step 85900, loss_disc 0.0126310065389, loss_gen 5.10504961014

I wonder did you ever test on it? What kind of results can you get? Or do you have any idea how to correct this?

Thanks in advance

Err result image about Info-GAN in your README

Hi,

Info-GAN is an unsupervised learning, z_cat in your code can control the Digit type, but the generate digit label will not be as same as your a in generate.py, it just looks like a cluster. The true result should be like this:

a

4 3 4 8 1 1 3 6 1 4
9 8 0 9 3 6 9 6 1 4
6 9 0 1 0 3 3 5 7 7
7 1 1 4 0 6 2 5 0 9
0 9 3 7 2 6 8 9 9 3
7 8 2 4 7 5 6 8 1 4
9 5 8 2 2 5 0 9 6 1
2 3 2 0 0 5 7 7 1 8
1 9 8 4 6 2 1 4 5 4
3 6 1 2 3 1 7 0 3 0

`fake.png'
fake

sample.png
sample

In fact, when z_cat is 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, the generate digit is 4 but not 0 in the above result. It's a random correspondence. I think you have attacted the result image from AC-GAN but not Info-GAN, please check it again.

I can not get the same result in run zhifu code

hi I download your code while it can not run, because the queue runner is always for waitting . so I change the code a little, for examlpe:
`def input_pipeline(self, batch_size, num_epochs=None, aug=False):

    image_batch=[]
    label_batch=[]
    for i in range(batch_size):
        img_path=self.image_names[self.qindex]
        img=Image.open(img_path)
        array = np.array(img)
        array.resize((28,280,1))
        image_batch.append(array)
        label_batch.append(self.labels[self.qindex])
        self.qindex = self.qindex + 1
        if(self.qindex == self.image_lenth):
            self.qindex =0
    image_batch=np.array(image_batch)
    label_batch=np.array(label_batch)
    return image_batch, label_batch`

the train step is 20000
the part of result
[test] the step 14801 accuracy 0.7265625 spend time 10.785616874694824
the loss : 1.21366
========Begin eval stage =========
[test] the step 14901 accuracy 0.6484375 spend time 11.592663049697876
the loss : 1.03953
========Begin eval stage =========
[test] the step 15001 accuracy 0.6171875 spend time 12.94074010848999
the loss : 1.27879
========Begin eval stage =========
[test] the step 15101 accuracy 0.671875 spend time 11.467655897140503
the loss : 0.966799
========Begin eval stage =========
[test] the step 15201 accuracy 0.6640625 spend time 12.628722190856934
the loss : 1.12343
========Begin eval stage =========
[test] the step 15301 accuracy 0.6796875 spend time 12.736728429794312
the loss : 1.43497
========Begin eval stage =========
[test] the step 15401 accuracy 0.6875 spend time 12.109692573547363
the loss : 1.17038
========Begin eval stage =========
[test] the step 15501 accuracy 0.59375 spend time 12.125693559646606
the loss : 1.19976
========Begin eval stage =========
[test] the step 15601 accuracy 0.6796875 spend time 14.316818952560425
the loss : 1.20551
========Begin eval stage =========
[test] the step 15701 accuracy 0.625 spend time 13.745786190032959
the loss : 0.996233
========Begin eval stage =========
[test] the step 15801 accuracy 0.609375 spend time 22.57629132270813
the loss : 1.08622
========Begin eval stage =========
[test] the step 15901 accuracy 0.6328125 spend time 17.0779767036438
the loss : 0.936256
========Begin eval stage =========
[test] the step 16001 accuracy 0.65625 spend time 15.478885412216187
the loss : 1.23139
========Begin eval stage =========
[test] the step 16101 accuracy 0.59375 spend time 21.262216091156006
the loss : 0.893639
========Begin eval stage =========
[test] the step 16201 accuracy 0.625 spend time 19.125093936920166
the loss : 1.02303
========Begin eval stage =========
[test] the step 16301 accuracy 0.6796875 spend time 18.563061714172363
the loss : 1.05793
========Begin eval stage =========
[test] the step 16401 accuracy 0.6484375 spend time 12.70172643661499
the loss : 1.01296
========Begin eval stage =========
[test] the step 16501 accuracy 0.671875 spend time 11.184639692306519
the loss : 1.08142
========Begin eval stage =========
[test] the step 16601 accuracy 0.671875 spend time 11.707669734954834
the loss : 1.10822
========Begin eval stage =========
[test] the step 16701 accuracy 0.6875 spend time 12.335705518722534
the loss : 0.899556
========Begin eval stage =========
[test] the step 16801 accuracy 0.671875 spend time 12.702726602554321
the loss : 0.931046
========Begin eval stage =========
[test] the step 16901 accuracy 0.6796875 spend time 12.334705352783203
the loss : 1.01363
========Begin eval stage =========
[test] the step 17001 accuracy 0.640625 spend time 11.968684673309326
the loss : 0.741938

Though the code can run ,but the result leave much to be desired。the accucess of train process the hightest is 72% and the loss about 1.21366。 Hope you can point out what's the problem here or how to fix the problem of queue runner . Thank you very much!

I can't get the same results as you.

Hi, I downloaded your code and then run it in linux server, I didn't change the code , just modifed some function parameter name because of the issue of tensorflow versions.
I ran train.py first and successfully generated checkpoint documents.
information printed:

cur epoch 49 update l_d step 84182, loss_disc 0.171038478613, loss_gen 7.14091253281
cur epoch 50 update l_d step 85900, loss_disc 0.114559516311, loss_gen 8.29001522064
W tensorflow/core/kernels/queue_base.cc:294] _2_test/input_producer/fraction_of_4096_full/fraction_of_4096_full: Skipping cancelled enqueue attempt with queue not closed
W tensorflow/core/kernels/queue_base.cc:294] _4_valid_1/random_shuffle_queue: Skipping cancelled enqueue attempt with queue not closed
W tensorflow/core/kernels/queue_base.cc:294] _1_valid/input_producer/fraction_of_4096_full/fraction_of_4096_full: Skipping cancelled enqueue attempt with queue not closed
W tensorflow/core/kernels/queue_base.cc:294] _3_test_1/random_shuffle_queue: Skipping cancelled enqueue attempt with queue not closed
W tensorflow/core/kernels/queue_base.cc:294] _0_train/input_producer/fraction_of_4096_full/fraction_of_4096_full: Skipping cancelled enqueue attempt with queue not closed

Then I ran generate.py,
information printed:

(100, 50)
Tensor("generator/fully_connected/Relu:0", shape=(100, 1024), dtype=float32)
gen (100, 14, 14, 64)
[2 2 4 3 5 6 4 1 2 7 1 2 5 9 7 7 7 2 5 9 4 3 1 4 7 1 3 3 2 1 9 0 3 8 1 0 5
2 5 5 5 5 1 0 5 8 4 4 8 2 0 6 3 7 8 6 9 7 0 8 7 4 4 4 1 0 1 2 5 0 5 8 7 4
1 0 5 4 2 0 8 4 3 5 9 9 8 2 4 3 8 2 7 3 5 9 0 2 5 4]

but I can only generate images of number 1 and 7, I ran the code several times but did not get perfect results like you yet.
Sorry I can't attach image here, I run the code by GPU, can you tell me why? thank you!

TypeError: concat() got an unexpected keyword argument 'axis'

最近在学习TF,研究大牛的代码报类型错误,具体报错位置见https://github.com/burness/tensorflow-101/blob/master/zhihu_code/src/train.py 的118行和119行,

我是刚学习的菜鸟,不知道是不是版本问题(我尝试了1.0.0和0.0.2两个版本,都报错了)。

解决办法:
out_score = tf.concat(values=[out0, out1, out2, out3, out4, out5, out6, out7, out8, out9], concat_dim=1, name="concat") ## axis=1 改为 concat_dim=1 out_final = tf.cast(tf.concat(values=[out0_argmax, out1_argmax, out2_argmax, out3_argmax, out4_argmax, out5_argmax, out6_argmax, out7_argmax, out8_argmax, out9_argmax], concat_dim=1), tf.int32)

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.