Python tensorflow_hub.load_module_spec() Examples
The following are 5
code examples of tensorflow_hub.load_module_spec().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow_hub
, or try the search function
.
Example #1
Source File: tf_hub.py From training_results_v0.5 with Apache License 2.0 | 5 votes |
def eval_from_hub(model_dir, input_fn, eval_steps): """Eval using hub module.""" hub_module_spec = hub.load_module_spec(model_dir) run_config = tf.estimator.RunConfig(model_dir=model_dir) image_classifier = tf.estimator.Estimator( model_fn=_make_model_fn(hub_module_spec), config=run_config, params={}) eval_results = image_classifier.evaluate(input_fn=input_fn, steps=eval_steps) tf.logging.info('Evaluation results: %s' % eval_results)
Example #2
Source File: tf_hub.py From tpu_models with Apache License 2.0 | 5 votes |
def eval_from_hub(model_dir, input_fn, eval_steps): """Eval using hub module.""" hub_module_spec = hub.load_module_spec(model_dir) run_config = tf.estimator.RunConfig(model_dir=model_dir) image_classifier = tf.estimator.Estimator( model_fn=_make_model_fn(hub_module_spec), config=run_config, params={}) eval_results = image_classifier.evaluate(input_fn=input_fn, steps=eval_steps) tf.logging.info('Evaluation results: %s' % eval_results)
Example #3
Source File: metaqa.py From language with Apache License 2.0 | 5 votes |
def get_text_module_input_name(): """Get the tag used for inputs to the text module. Returns: a string, probably "default" """ module_spec = hub.load_module_spec(FLAGS.module_handle) return list(module_spec.get_input_info_dict())[0]
Example #4
Source File: tf_hub.py From class-balanced-loss with MIT License | 5 votes |
def eval_from_hub(model_dir, input_fn, eval_steps): """Eval using hub module.""" hub_module_spec = hub.load_module_spec(model_dir) run_config = tf.estimator.RunConfig(model_dir=model_dir) image_classifier = tf.estimator.Estimator( model_fn=_make_model_fn(hub_module_spec), config=run_config, params={}) eval_results = image_classifier.evaluate(input_fn=input_fn, steps=eval_steps) tf.logging.info('Evaluation results: %s' % eval_results)
Example #5
Source File: tf_image_processor.py From valan with Apache License 2.0 | 4 votes |
def __init__(self, tf_hub_module_spec=None, tf_hub_module_path=None,): """Creates an instance to extract image features from a pre-trained model. The model to use may be specified as a TF-hub module (either by ModuleSpec or path) or as an Inception V4 model checkpoint. If a TF-hub module is given, it is assumed to conform to the interface described in [1]. Its default signature should take an input 'images' Tensor with shape [batch_size, height, width, num_channels=3] and return a [batch_size, feature_dim] Tensor of features. Pass `tf_hub_module_spec=make_module_spec_for_testing()` to stub out the model for tests. [1] https://www.tensorflow.org/hub/common_signatures/images#image_feature_vector Args: tf_hub_module_spec: `hub.ModuleSpec` or None, the TF-hub module to load. tf_hub_module_path: str or None, the location of the TF-hub module to load in a format understood by `load_module_spec()` (URL, '@internal/module/name', '/on/disk/path', etc.) Raises: ValueError: if not exactly one kwarg specifying the model is given. """ self.spec_str = None # String describing the model/module being used. # Input and output tensors for the image to representation computation. # The output tensor will depend on the model options. self._input = None self._output = None self._session = None num_kwargs = sum( int(kwarg is not None) for kwarg in [tf_hub_module_spec, tf_hub_module_path]) if num_kwargs != 1: raise ValueError( 'Must provide exactly one of "tf_hub_module_spec", ' '"tf_hub_module_path".') if tf_hub_module_spec: self.spec_str = 'user_provided_module' self._initialize_from_hub_module(tf_hub_module_spec) elif tf_hub_module_path: self.spec_str = tf_hub_module_path self._initialize_from_hub_module(hub.load_module_spec(tf_hub_module_path))