我尝试重新训练开始!! 当我使用tensorflow 1.2.0和1.2.0训练脚本时,我会出错:
2019-01-21 22:02:38.904542: W
tensorflow/core/framework/op_def_util.cc:355] Op
BatchNormWithGlobalNormalization is deprecated. It will cease to work
in GraphDef version 9. Use tf.nn.batch_normalization(). 2019-01-21
22:02:39.036440: I tensorflow/core/platform/cpu_feature_guard.cc:141]
Your CPU supports instructions that this TensorFlow binary was not
compiled to use: AVX2 Exception in thread "main"
java.lang.IllegalArgumentException: No Operation named [softmax] in
the Graph at
org.tensorflow.Session$Runner.operationByName(Session.java:372) at
org.tensorflow.Session$Runner.parseOutput(Session.java:381)
当我使用tensorflow 1.12.0和1.12.0训练模型时,我会出错:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid
GraphDef at org.tensorflow.Graph.importGraphDef(Native Method) at
org.tensorflow.Graph.importGraphDef(Graph.java:130)
我现在不怎么训练模型?我使用InceptionV3 我的命令文件是:python D://retrain.py --image_dir D:\ train 火车日志:https://nofile.io/f/QOCUJz8HW3h/log1.12.txt
Main java code : File file = new File("Java.jpg"); Image image = new
Image(file.toURI().toString()); imga.setImage(image); String
modelpath= "C:\\Users\\AngruAdminAlex\\Documents\\inception_dec_2015";
float verison=(float) 1.0; System.out.println("Opening: " +
modelpath); modelselected = true; graphDef =
readAllBytesOrExit(Paths.get(modelpath,
"tensorflow_inception_graph.pb")); labels =
readAllLinesOrExit(Paths.get(modelpath,
"imagenet_comp_graph_label_strings.txt")); File file1 = new File
("Java.jpg"); String imagepath="Java.jpg"; System.out.println("Image
Path: " + imagepath); BufferedImage img = ImageIO.read(file1); //read
image System.out.println("Reading complete."); byte[] imageBytes =
readAllBytesOrExit(Paths.get(imagepath)); byte data[] = imageBytes;
FileOutputStream out = new FileOutputStream("buffer.rawfile");
out.write(data); out.close(); try (Tensor image1 =
Tensor.create(imageBytes)) { float[] labelProbabilities =
executeInceptionGraph(graphDef, image1); int bestLabelIdx =
maxIndex(labelProbabilities); System.out.println( String.format( "BEST
MATCH: %s (%.2f likely)", labels.get(bestLabelIdx),
labelProbabilities[bestLabelIdx] * 100f)); results.setText(
String.format( "BEST MATCH: %s (%.2f likely)",
labels.get(bestLabelIdx), labelProbabilities[bestLabelIdx] * 100f)); }
}
答案 0 :(得分:0)
如何为此代码训练InceptionV3
Tensor result =
s.runner().feed("DecodeJpeg/contents",image).fetch("softmax").run().get(0)) {
到Tensor result = s.runner().feed("DecodeJpeg/contents", image).fetch("final_result").run().get(0)) {
python (path to retrain.py) --image_dir (path to image) -- output_graph (path to graph files(.pb) -- output_labels(path to label(.txt)