Comments (7)
Looking at official documentation (https://www.tensorflow.org/guide/saved_model#savedmodels_from_estimators), it seems that when you load a saved model from disk, what you get back is not an estimator. But you should still be able to call predict on that object, by defining your own custom prediction function like is done in that documentation and then providing that custom predict function to the WitConfigBuilder.
Let me know if an approach similar to the predict(x) function in that link works for you.
from what-if-tool.
@jameswex When using the predict function:
def predict(x):
example = tf.train.Example()
example.features.feature["x"].float_list.value.extend([x])
return imported.signatures["predict"](examples=tf.constant([example.SerializeToString()]))
config_builder = WitConfigBuilder(test_examples, feats + ['level']).set_estimator_and_feature_spec(predict, feature_spec = [])
WitWidget(config_builder, height=1600)
(With imported being
imported = tf.saved_model.load(export_dir=trained_model_path)
from the type <tensorflow.python.training.tracking.tracking.AutoTrackable at 0x7f3d71e456a0>
)
I get the error:
"<_Rendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "DNS resolution failed" debug_error_string = "{"created":"@1578211571.031196087","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3818,"referenced_errors":[{"created":"@1578211571.031189371","description":"Resolver transient failure","file":"src/core/ext/filters/client_channel/resolving_lb_policy.cc","file_line":268,"referenced_errors":[{"created":"@1578211571.031187685","description":"DNS resolution failed","file":"src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc","file_line":357,"grpc_status":14,"referenced_errors":[{"created":"@1578211571.031167691","description":"C-ares status is not ARES_SUCCESS: Domain name not found","file":"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc","file_line":244}]}]}]}" >"
from what-if-tool.
Since you have defined your own custom prediction function, instead of using a tf.Estimator, you want to change your code to something like:
config_builder = WitConfigBuilder(test_examples, feats + ['level']).set_custom_predict_fn(predict) WitWidget(config_builder, height=1600)
from what-if-tool.
@jameswex OK this is better now but I have a problem - my features are from type list:
features {
feature {
key: "b_number"
value {
int64_list {
value: 1
}
}
}
feature {
key: "c_type"
value {
bytes_list {
value: "motor"
}
}
}
So I get the error:
[features { feature { key: "bearing_number" value { int64_list { value: 1 has type list, but expected one of: int, long, float
I have total of more 30 features and they are all from types float_list / int_list / bytes_list
, what is the best way to convert them all to int / long / float?
from what-if-tool.
Are you able to share a colab notebook with your code that loads up your saved model so I could see the issue? I'm imagining that perhaps the saved model as reloaded wants the example in a very different format than the tf.Example format and so some conversion function will be necessary but its hard to know what that will need to be without playing with it myself.
from what-if-tool.
@jameswex It's internal code so it will be problematic to share.. I'll try to play with it and make it work, Thanks!
from what-if-tool.
Looking at the example in the link I sent above, it seems your custom predict fn might need to take the provided tf.Examples, serialize them and wrap them in a tf.constant like:
def predict(examples): return imported.signatures["predict"]( examples=tf.constant([ex.SerializeToString() for ex in examples]))
That would be due to how the restored saved model accepts inputs. But I haven't directly worked with this type of restored model before.
from what-if-tool.
Related Issues (20)
- Does what-if-tool support lightgbm or xgboost or scikit learning models? HOT 1
- Replacing model with predictions data HOT 1
- GOOGLE APPLICATION CREDENTIALS HOT 3
- Can this work just on data without any model input? HOT 1
- Can the dashboard be changed according to our need? HOT 1
- what if tool for ranking model? HOT 1
- how to install what if in managed notebook of vertex ai? HOT 3
- UnboundLocalError("local variable 'values' referenced before assignment") HOT 7
- what-if tool unable to return predictions - InactiveRpcError
- Enabling Persistence with what-if tensorboard plugin
- Data loading issue at scale with tensorboard what-if plugin
- Error when trying to reproduce example notebook locally HOT 6
- Custom Sprite Thumbnail Dimensions HOT 1
- Unable to import Witwidget
- Cant use fairness solution for regression so In that case How to mitigate the bias for the regression model? HOT 1
- ERROR: An error occurred during the fetch of repository 'zlib': HOT 1
- Uncaught (in promise) Error: Tensorflow Op is not supported: _FusedConv2D HOT 5
- Failed to load view class 'WITView' from module 'wit-widget'
- Predict in Datapoint-Editor leads to non-deterministic behavior HOT 1
- What If tool returning error HOT 1
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 what-if-tool.