資源簡介
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
github上的retrain.py 是錯的不能運行,這個可以運行。
代碼片段和文件信息
#?coding:utf-8
#?這個代碼出處?原來的有錯?所以使用了這個博主修改后的代碼?https://www.cnblogs.com/EstherLjy/p/9861034.html
#?Copyright?2015?The?TensorFlow?Authors.?All?Rights?Reserved.
#
#?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
#?you?may?not?use?this?file?except?in?compliance?with?the?License.
#?You?may?obtain?a?copy?of?the?License?at
#
#?????http://www.apache.org/licenses/LICENSE-2.0
#
#?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
#?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
#?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
#?See?the?License?for?the?specific?language?governing?permissions?and
#?limitations?under?the?License.
#?==============================================================================
r“““Simple?transfer?learning?with?Inception?v3?or?Mobilenet?models.
With?support?for?TensorBoard.
This?example?shows?how?to?take?a?Inception?v3?or?Mobilenet?model?trained?on
ImageNet?images?and?train?a?new?top?layer?that?can?recognize?other?classes?of
images.
The?top?layer?receives?as?input?a?2048-dimensional?vector?(1001-dimensional?for
Mobilenet)?for?each?image.?We?train?a?softmax?layer?on?top?of?this
representation.?Assuming?the?softmax?layer?contains?N?labels?this?corresponds
to?learning?N?+?2048*N?(or?1001*N)??model?parameters?corresponding?to?the
learned?biases?and?weights.
Here‘s?an?example?which?assumes?you?have?a?folder?containing?class-named
subfolders?each?full?of?images?for?each?label.?The?example?folder?flower_photos
should?have?a?structure?like?this:
~/flower_photos/daisy/photo1.jpg
~/flower_photos/daisy/photo2.jpg
...
~/flower_photos/rose/anotherphoto77.jpg
...
~/flower_photos/sunflower/somepicture.jpg
The?subfolder?names?are?important?since?they?define?what?label?is?applied?to
each?image?but?the?filenames?themselves?don‘t?matter.?Once?your?images?are
prepared?you?can?run?the?training?with?a?command?like?this:
bash:
bazel?build?tensorflow/examples/image_retraining:retrain?&&?\
bazel-bin/tensorflow/examples/image_retraining/retrain?\
????--image_dir?~/flower_photos
Or?if?you?have?a?pip?installation?of?tensorflow?‘retrain.py‘?can?be?run
without?bazel:
bash:
python?tensorflow/examples/image_retraining/retrain.py?\
????--image_dir?~/flower_photos
You?can?replace?the?image_dir?argument?with?any?folder?containing?subfolders?of
images.?The?label?for?each?image?is?taken?from?the?name?of?the?subfolder?it‘s
in.
This?produces?a?new?model?file?that?can?be?loaded?and?run?by?any?TensorFlow
program?for?example?the?label_image?sample?code.
By?default?this?script?will?use?the?high?accuracy?but?comparatively?large?and
slow?Inception?v3?model?architecture.?It‘s?recommended?that?you?start?with?this
to?validate?that?you?have?gathered?good?training?data?but?if?you?want?to?deploy
on?resource-limited?platforms?you?can?try?the?‘--architecture‘?flag?with?a
Mobilenet?model.?For?example:
bash:
python?tensorflow/examples/image_retraining/retrain.py?\
????--image_
- 上一篇:mapnik&python的安裝手冊
- 下一篇:python資料.txt
評論
共有 條評論