Comments (7)
Hi! Do you mean changing the name in the saved model from StatefulPartitionedCall:1
to B
?
from tfgo.
Hi! Do you mean changing the name in the saved model from
StatefulPartitionedCall:1
toB
?
Just need to match the 4 scores we get from StatefulPartitionedCall:0~3 to the 4 events [A,B,C,D] without running saved_model_cli
from tfgo.
- In python how do you load the saved model, and feed the model to get the values A,B,C,D (and their values)
- The same thing, but in Go
Because I expect the behavior to be the same, given the same saved model and the same inputs
from tfgo.
In python, I simply run
model.predict(input)
which gives me the 4 task output in a python list
[array([[0.1545861]], dtype=float32), array([[0.27176663]], dtype=float32), array([[0.04840082]], dtype=float32), array([[0.16918059]], dtype=float32)]
In go, I run
results0 := p.Model.Exec([]tf.Output{
p.Model.Op("StatefulPartitionedCall", 0),
}, input)
results1 := p.Model.Exec([]tf.Output{
p.Model.Op("StatefulPartitionedCall", 1),
}, input)
results2 := p.Model.Exec([]tf.Output{
p.Model.Op("StatefulPartitionedCall", 2),
}, input)
results3 := p.Model.Exec([]tf.Output{
p.Model.Op("StatefulPartitionedCall", 3),
}, input)
The order of the output is different
[[0.1691806]]
[[0.04840079]]
[[0.15458608]]
[[0.27176666]]
When I train the model, I name the tasks in the following order
"TaskTypes": [
"NAVIGATE_IMP",
"PURCHASE_NAVIGATE",
"LIKE_NAVIGATE",
"ADDTOCART_NAVIGATE"
],
But running saved_model_cli show ...
suggests the output index does not match how I construct the model. The output names seems sorted by alpha order.
outputs['ADDTOCART_NAVIGATE'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: StatefulPartitionedCall:0
outputs['LIKE_NAVIGATE'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: StatefulPartitionedCall:1
outputs['NAVIGATE_IMP'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: StatefulPartitionedCall:2
outputs['PURCHASE_NAVIGATE'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: StatefulPartitionedCall:3
from tfgo.
You should first check in Python - after importing the SavedModel with tf.saved_model.load
and not with the Keras equivalent - if the output is the expected one.
We need to test this to understand if the SavedModel used in Python in the same way it's used from Go has the same behavior or not. This can give us an hint on where to look (if it's something in common, than there's some pre/post processing to do. If the behavior is different maybe the C library used in Go has some problem
from tfgo.
OK, I am running
imported = tf.saved_model.load(model_path)
f = imported.signatures["serving_default"]
print(f)
which gives me
Args:
...
Returns:
{'ADDTOCART_NAVIGATE': <1>, 'LIKE_NAVIGATE': <2>, 'NAVIGATE_IMP': <3>, 'PURCHASE_NAVIGATE': <4>}
<1>: float32 Tensor, shape=(None, 1)
<2>: float32 Tensor, shape=(None, 1)
<3>: float32 Tensor, shape=(None, 1)
<4>: float32 Tensor, shape=(None, 1)
The output seems returned as a map, keyed with output tensor name. Then it explains why the order does not match.
from tfgo.
I guess, thus, the problem is solved. I mean, you just need to correctly map the p.Model.Op("StatefulPartitionedCall", index),
with the index you expect.
Closing since this is not a tfgo problem.
from tfgo.
Related Issues (20)
- tf.Variable support HOT 1
- windows installation error HOT 5
- loading model HOT 2
- cc1.exe: sorry, unimplemented: 64-bit mode not compiled in HOT 1
- Error: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at lookup_table_op.cc:929 : FAILED_PRECONDITION: Table not initialized. HOT 1
- SparseTensor support HOT 2
- Failed to go get tfgo HOT 3
- tensor example support HOT 6
- Potential memory leak on reloading model HOT 8
- libtensorflow.so: .dynsym local symbol at index 3 (>= sh_info of 3) HOT 2
- Thread safety HOT 2
- Panic vs Error HOT 2
- Reading jpg image from disk and passing as input to a pretrained model loaded from disk HOT 4
- Error building "Getting Started" example: rebuild TensorFlow with the appropriate compiler flags HOT 5
- Can I use tfgo for tensorflow 2.11.x? HOT 2
- Convert opencv's `mat` to tfgo's `tensor` HOT 7
- Dark Souls level frustration with compilation project with this library HOT 1
- Discrepancy between python and go outputs HOT 2
- tfgo Object detection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfgo.