I'm trying to execute a prediction on a model that I trained using "Finetuning AlexNet with TensorFlow" https://kratzert.github.io/2017/02/24/finetuning-alexnet-with-tensorflow.html
I saved the model using tf.saved_model.builder.SavedModelBuilder in Python, and loaded the model in Java using SavedModelBundle.load.
the main part of the code is:
SavedModelBundle smb = SavedModelBundle.load(path, "serve");
Session s = smb.session();
byte[] imageBytes = readAllBytesOrExit(Paths.get(path));
Tensor image = constructAndExecuteGraphToNormalizeImage(imageBytes);
Tensor result = s.runner().feed("input_tensor", image).fetch("fc8/fc8").run().get(0);
final long[] rshape = result.shape();
if (result.numDimensions() != 2 || rshape[0] != 1) {
throw new RuntimeException(
String.format(
"Expected model to produce a [1 N] shaped tensor where N is the number of labels, instead it produced one with shape %s",
Arrays.toString(rshape)));
}
int nlabels = (int) rshape[1];
float [] a = result.copyTo(new float[1][nlabels])[0];`
I'm getting this Exception:
Exception in thread "main" java.lang.IllegalArgumentException: You must feed a value for placeholder tensor 'Placeholder_1' with dtype float [[Node: Placeholder_1 = Placeholder_output_shapes=[[]], dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]]
I saw that the code above worked for some people, and I can't figure out what's missing here. Note that the net is familiar with the nodes "input_tensor" and "fc8/fc8", since it didn't say that it doesn't know them.