Pamungkas Jayuda
Pamungkas Jayuda

Reputation: 1280

Tensorflow on Golang Model sessionn run error : nil-Operation. If the Output was created with a Scope object, see Scope.Err() for details

iam use golang with tensorflow model. With this code : ```

    output, err := sessionModel.Run(
    map[tf.Output]*tf.Tensor{
        graphModel.Operation("input").Output(0): tensor,
    },
    []tf.Output{
        graphModel.Operation("output").Output(0),
    },
    nil)

```

But show error : 2019/01/07 18:07:48 http: panic serving [::1]:55262: nil-Operation. If the Output was created with a Scope object, see Scope.Err() for details.

I am already check tensor contain tensor from image file. Any recomendation ? Thanks anyway

Upvotes: 2

Views: 1044

Answers (2)

Akavall
Akavall

Reputation: 86356

I would like to add to @nessuno great answer, that I needed to do: my_model.inputs and my_model.outputs to get the proper names. For example:

> my_model.inputs
[<tf.Tensor 'dense_1_input:0' shape=(?, 7) dtype=float32>
> my_model.outputs
[<tf.Tensor 'my_output/BiasAdd:0' shape=(?, 2) dtype=float32>

Therefore, my input and output nodes are dense_1_input and my_output/BiasAdd (not my_output!)

Upvotes: 1

nessuno
nessuno

Reputation: 27070

The error says the Output attribute (of a certain the node) is a nil operation.

Hence graphModel.Operation("input").Operation(0) or graphModel.Operation("output").Output(0) returns nil.

To correct this, you have to refer to an existing node in the graph because there's no a tensor named input or a tensor named output in the graph.

From the python code you used to export the model you can find the complete name of your input and output tensors. Just access the .name attribute of your input placeholder and of your output node, to get the correct name to use in Go.

Also, the Go bindings are complex to use, especially if you want to run some preprocessing operations on the input image. I suggest you use galeone/tfgo instead of directly using the bindings (Note that I am the author of this repo).

Upvotes: 3

Related Questions