Comments (7)
TF2.0 is not yet supported. We are actively working on it, so check back in a few weeks.
from model-analysis.
I understand. Therefore, I used
estimator_model = tf.keras.estimator.model_to_estimator(new_model,model_dir=TF_MODEL_DIR)]]
The error is raising from the VGG model that is being transferred
`# Load model
new_model = keras.models.load_model(model_name)
new_model.summary()
# keras model to estimator
estimator_model = tf.keras.estimator.model_to_estimator(new_model,model_dir=TF_MODEL_DIR)]]
# The receiver function for the estimator
def eval_input_receiver_1_fn():
serialized_tf_example = tf.compat.v1.placeholder(dtype=tf.string, shape=[None], name='input_example_placeholder')
receiver_tensors = {'examples': serialized_tf_example}
validation_features_columns = [tf.feature_column.numeric_column("image",shape=(192,192)),
tf.feature_column.categorical_column_with_vocabulary_list("label",["normal_healthy","sick"])]
feature_spec = tf.feature_column.make_parse_example_spec(validation_features_columns)
features = tf.io.parse_example(serialized_tf_example, feature_spec)
return tfma.export.EvalInputReceiver(
features=features,
receiver_tensors=receiver_tensors,
labels=features['label'])
import os
import shutil
from pathlib import Path
def up_one_dir(path):
"""Move all file in path up one
"""
parent_dir = str(Path(path).parents[0])
for f in os.listdir(path):
shutil.copy(os.path.join(path,f),parent_dir)
#shutil.rmtree(path)
up_one_dir(KERAS_FOLDER)
tfma.export.export_eval_savedmodel(estimator=estimator_model,
export_dir_base=EXPORT_DIR,
eval_input_receiver_fn=eval_input_receiver_1_fn)
The following error is fired regarding the pre-trained model features:
KeyErrorTraceback (most recent call last)
<ipython-input-137-b275096a314a> in <module>()
1 tfma.export.export_eval_savedmodel(estimator=estimator_model,
2 export_dir_base=EXPORT_DIR,
----> 3 eval_input_receiver_fn=eval_input_receiver_1_fn)
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_model_analysis/util.pyc in wrapped_fn(*args, **kwargs)
171 (fn.__name__, kwargs.keys()))
172
--> 173 return fn(**kwargs_to_pass)
174
175 return wrapped_fn
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_model_analysis/eval_saved_model/export.pyc in export_eval_savedmodel(estimator, export_dir_base, eval_input_receiver_fn, serving_input_receiver_fn, assets_extra, checkpoint_path)
472 },
473 assets_extra=assets_extra,
--> 474 checkpoint_path=checkpoint_path)
475
476
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow/python/util/deprecation.pyc in new_func(*args, **kwargs)
322 'in a future version' if date is None else ('after %s' % date),
323 instructions)
--> 324 return func(*args, **kwargs)
325 return tf_decorator.make_decorator(
326 func, new_func, 'deprecated',
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/contrib/estimator/python/estimator/export.pyc in export_all_saved_models(estimator, export_dir_base, input_receiver_fn_map, assets_extra, as_text, checkpoint_path)
206 assets_extra=assets_extra,
207 as_text=as_text,
--> 208 checkpoint_path=checkpoint_path)
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/estimator.pyc in experimental_export_all_saved_models(self, export_dir_base, input_receiver_fn_map, assets_extra, as_text, checkpoint_path)
820 self._add_meta_graph_for_mode(
821 builder, input_receiver_fn_map, checkpoint_path,
--> 822 save_variables, mode=model_fn_lib.ModeKeys.EVAL)
823 save_variables = False
824 if input_receiver_fn_map.get(model_fn_lib.ModeKeys.PREDICT):
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/estimator.pyc in _add_meta_graph_for_mode(self, builder, input_receiver_fn_map, checkpoint_path, save_variables, mode, export_tags, check_variables)
895 labels=getattr(input_receiver, 'labels', None),
896 mode=mode,
--> 897 config=self.config)
898
899 export_outputs = model_fn_lib.export_outputs_for_mode(
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/estimator.pyc in _call_model_fn(self, features, labels, mode, config)
1110
1111 logging.info('Calling model_fn.')
-> 1112 model_fn_results = self._model_fn(features=features, **kwargs)
1113 logging.info('Done calling model_fn.')
1114
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/keras.pyc in model_fn(features, labels, mode)
276
277 model = _clone_and_build_model(mode, keras_model, custom_objects, features,
--> 278 labels)
279 model_output_names = []
280 # We need to make sure that the output names of the last layer in the model
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/keras.pyc in _clone_and_build_model(mode, keras_model, custom_objects, features, labels)
184 K.set_learning_phase(mode == model_fn_lib.ModeKeys.TRAIN)
185 input_tensors, target_tensors = _convert_estimator_io_to_keras(
--> 186 keras_model, features, labels)
187
188 compile_clone = (mode != model_fn_lib.ModeKeys.PREDICT)
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/keras.pyc in _convert_estimator_io_to_keras(keras_model, features, labels)
157
158 input_tensors = _to_ordered_tensor_list(
--> 159 features, input_names, 'features', 'inputs')
160 target_tensors = _to_ordered_tensor_list(
161 labels, output_names, 'labels', 'outputs')
/usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow_estimator/python/estimator/keras.pyc in _to_ordered_tensor_list(obj, key_order, obj_name, order_name)
139 order_name=order_name, order_keys=set(key_order),
140 obj_name=obj_name, obj_keys=set(obj.keys()),
--> 141 different_keys=different_keys))
142
143 return [_convert_tensor(obj[key]) for key in key_order]
KeyError: "The dictionary passed into features does not have the expected inputs keys defined in the keras model.\n\tExpected keys: set([u'vgg16_input'])\n\tfeatures keys: set(['image', 'label'])\n\tDifference: set(['image', 'label', u'vgg16_input'])"
Can I make that work?
from model-analysis.
I should have been clearer. Support for TF 2.0 estimators (keras model_to_estimator or otherwise) is not yet supported.
That said, the error you are getting is because keras does not allow you to pass more features than the model defines. You need to either add vgg16_input to the model or remove it from the features.
from model-analysis.
Thank you so much for your response. will try to add to my features list. I want to make sure that I can have viz support for transfer models. Event if it is not perfect at the moment. will keep you posted if I have any additional issue. Thanks again, eilalan
from model-analysis.
It doesn't look like that I will able to load the TF 2.0 model with TF 1.13.1 that supports TFMA - an improper config error is being fired. I will wait for your updated version. Meanwhile, please let me know if you are familiar with other tools to analyze models that is saved as h5. Thanks, eilalan
from model-analysis.
I'm having a similar issue when attempting to use TFMA to slice and display statistics on raw features before they have gone through the TFTransform component. Are there any updates on this issue?
from model-analysis.
As of now, keras model_to_estimator requires that only the features used by the model be passed, so you would not be able to slice on additional features without additional work run another feature extractor in the pipeline.
+cc @tanzhenyu
from model-analysis.
Related Issues (20)
- Unable to use custom Keras metrics with TFX evaluator component HOT 4
- AttributeError: partially initialized module error, test.py HOT 2
- Incorrect Documentation for MetricConfig
- Custom multilabel Keras metrics: dynamically initialize weight shape HOT 1
- Fairness indicator metrics do not show up HOT 5
- Validation bug when using feature values as slicing specs HOT 2
- No longer compatible with Dataflow runner v1 after v0.29
- Renaming Custom Layer breaks TFMA Evaluator HOT 6
- Error in merge_accumulators when using keras metrics on dataflow HOT 3
- TFMA analyze_raw_data function support with MultiClassConfusionMatrixPlot HOT 3
- Analytics HOT 1
- Breaking changes: tfma.metrics.MetricComputation `preprocessor` argument changed from accepting beam DoFn to `preprocessors` accepting a list of `Preprocessor` HOT 1
- Move to numpy >=1.20 because <1.20 is difficult to build on Apple Silicon HOT 4
- TFMA on Flink does not seems to be parallelizing work. HOT 5
- only integer values should be passed to num_instances metric. HOT 3
- Render_plot is failing HOT 2
- Feat: Have ability to return the HTML rather than creating the plots HOT 1
- CVE in Pyarrow dependency HOT 1
- CNN HOT 2
- pip install tensorflow-model-analysis fails on WSL2 on Windows 11 HOT 2
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 model-analysis.