Tensorflow related
How to Retrain Inception's Final Layer for New Categories
步骤:
一 Installing TensorFlow on Ubuntu
https://www.tensorflow.org/install/install_linux
二 Install Bazel on Ubuntu
https://bazel.build/versions/master/docs/install-ubuntu.html
三 下载代码
git clone https://github.com/tensorflow/tensorflow.git
~/tensorflow$ ./configure
四 编译
bazelbuildtensorflow/examples/p_w_picpath_retraining:retrain
五 注意事项:
1bazel-bin/tensorflow/examples/label_p_w_picpath/label_p_w_picpath --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt --output_layer=final_result --p_w_picpath=/home/camille/Desktop/timg.jpg
命令报错:
017-06-20 12:52:52.774446: E tensorflow/examples/label_p_w_picpath/main.cc:350] Running model failed: Not found: FeedInputs: unable to find feed output input
解决方案:在后面加一句 --input_layer=Mul //this parameter update the input and output layer names to "Mul" and "final_result" respectively
2下载tensorflow 代码时,
git clone https://github.com/tensorflow/tensorflow.git
直接执行 bazel build tensorflow/examples/p_w_picpath_retraining:retrain
报错 build aborted
解决方案: 执行 ./configure
再执行 bazel build tensorflow/examples/p_w_picpath_retraining:retrain 就没问题了。
3 Bazel 安装之前一定要安装jdk
sudo apt-get install oracle-java8-installer
I recommend you to use Webup8 Oracle Java8 Installer
sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt-get install oracle-java8-installer
or
sudo apt update; sudo apt-get installoracle-java8-set-default
4 执行
bazel-bin/tensorflow/examples/p_w_picpath_retraining/retrain--p_w_picpath_dir~/flower_photos
时报错:1)
File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/p_w_picpath_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/util/tf_should_use.py", line 28, in <module>
from backports import weakref # pylint: disable=g-bad-import-order
ImportError: No module named backports
解决方案:安装所需module
sudopipinstallbackports.weakrefsudopip3installbackports.weakref报错2)Traceback(mostrecentcalllast):File"<string>",line1,in<module>ImportError:NomodulenamednumpyIsnumpyinstalled?解决方案:sudoapt-getinstallpython-numpy
5ImportError: No module named mock
实际上安装了,所以只能先删除再安装了
解决方案:
$sudorm-rf/usr/local/lib/python2.7/dist-packages/mock$sodorm-rf/usr/local/lib/python2.7/dist-packages/mock-2.0.0.dist-info
then type the following command to install mock
$sudopipinstall--upgrademock
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。