logo
down
shadow

Save tf.summary.image with Estimator API


Save tf.summary.image with Estimator API

By : juhjan
Date : October 17 2020, 03:08 PM
it should still fix some issue You shouldn't have to add a hook. Just add the tf.summary.image call anywhere in your model_fn/input_fn and the estimator should automatically add a summary hook for all summaries created.
code :


Share : facebook icon twitter icon
Tensorflow - Using tf.summary with 1.2 Estimator API

Tensorflow - Using tf.summary with 1.2 Estimator API


By : Junu Gurung
Date : March 29 2020, 07:55 AM
it helps some times Just for whoever have this question in the future, the selected solution doesn't work for me (see my comments in the selected solution).
Actually, with TF 1.2 Estimator API, one doesn't need to have summary_hook. I just have tf.summary.scalar("loss", loss) in the model_fn, and run the code without summary_hook. The loss is recorded and shown in the tensorboard. I'm not sure if TF API was changed after this and similar questions.
Tensorflow Estimator API save image summary in eval mode

Tensorflow Estimator API save image summary in eval mode


By : Tailians WWIPL
Date : March 29 2020, 07:55 AM
hope this fix your issue With TF1.4, you can pass tf.estimator.EstimatorSpec evaluation_hooks. The evaluation_hooks is a list of hooks, and you must add to it the following hook:
code :
# Create a SummarySaverHook
eval_summary_hook = tf.train.SummarySaverHook(
                                save_steps=1,
                                output_dir= self.job_dir + "/eval_core",
                                summary_op=tf.summary.merge_all())
# Add it to the evaluation_hook list
evaluation_hooks.append(eval_summary_hook)

#Now, return the estimator:
return tf.estimator.EstimatorSpec(
                mode=mode,
                predictions=predictions,
                loss=loss,
                train_op=train_op,
                training_hooks=training_hooks,
                eval_metric_ops=eval_metric_ops,
                evaluation_hooks=evaluation_hooks)
Creating an image summary only for a subset of validation set images using Tensorflow Estimator API

Creating an image summary only for a subset of validation set images using Tensorflow Estimator API


By : lockheart
Date : March 29 2020, 07:55 AM
help you fix your problem I figured out a solution that uses Estimator/Experiment API.
First you need to modify your Dataset input to not only provide labels and features, but also some form of an identifier for each sample (in my case it was a filename). Then in the hyperparameters dictionary (params argument) you need to specify which of the validation samples you want to plot. You also will have to pass the model_dir in those parameters. For example:
code :
params = tf.contrib.training.HParams(
        model_dir=model_dir,
        images_to_plot=["100307_EMOTION.nii.gz", "100307_FACE-SHAPE.nii.gz",
                        "100307_GAMBLING.nii.gz", "100307_RELATIONAL.nii.gz",
                        "100307_SOCIAL.nii.gz"]
    )

learn_runner.run(
        experiment_fn=experiment_fn,
        run_config=run_config,
        schedule="train_and_evaluate",
        hparams=params
    )
if mode == tf.contrib.learn.ModeKeys.EVAL:
    summaries = []
    for image_to_plot in params.images_to_plot:
        is_to_plot = tf.equal(tf.squeeze(filenames), image_to_plot)

        summary = tf.cond(is_to_plot,
                          lambda: tf.summary.image('predicted', predictions),
                          lambda: tf.summary.histogram("ignore_me", [0]),
                          name="%s_predicted" % image_to_plot)
        summaries.append(summary)

    evaluation_hooks = [tf.train.SummarySaverHook(
        save_steps=1,
        output_dir=os.path.join(params.model_dir, "eval"),
        summary_op=tf.summary.merge(summaries))]
else:
    evaluation_hooks = None
return tf.estimator.EstimatorSpec(
    mode=mode,
    predictions=predictions,
    loss=loss,
    train_op=train_op,
    evaluation_hooks=evaluation_hooks
)
tf.summary.image seems not work for estimator prediction

tf.summary.image seems not work for estimator prediction


By : Ivo Chaves Ríos
Date : March 29 2020, 07:55 AM
wish helps you I would assume that you need to put the summary ops (histogram/image) before calling merge_all so that merge_all actually has something to merge.
code :
...
tf.summary.histogram("logit",logits)
tf.summary.image('feat', feat)
summary_hook = tf.train.SummarySaverHook(
    save_secs=2,
    output_dir='summary',
    scaffold=tf.train.Scaffold(summary_op=tf.summary.merge_all()))
    #summary_op=tf.summary.merge_all())
if mode == tf.estimator.ModeKeys.PREDICT:
    return tf.estimator.EstimatorSpec(mode, predictions=preds, prediction_hooks=[summary_hook])
...
How to add an image to summary during evaluation when using Estimator?

How to add an image to summary during evaluation when using Estimator?


By : bram_de_jong
Date : March 29 2020, 07:55 AM
With these it helps The way I make it work is by passing a tf.train.SummarySaverHook under the evaluation mode and then declaring it to the tf.estimator.EstimatorSpec at evaluation_hooks=. images is a list of the desired tf.summary.image you want to print during evaluation. example:
code :
eval_summary_hook = tf.train.SummarySaverHook(output_dir=params['eval_save_path'], summary_op=images, save_secs=120)

spec = tf.estimator.EstimatorSpec(mode=mode, predictions=y_pred, loss=loss, eval_metric_ops=eval_metric_ops,
                                      evaluation_hooks=[eval_summary_hook])
Related Posts Related Posts :
  • Django - stop synchronisation between different variables based on filters on same object
  • Using python together with knitr
  • Difference between <type 'classobj'>, <type 'object'>?
  • what is top level module in Python?
  • Is there a query method or similar for pandas Series (pandas.Series.query())?
  • Deleting DataFrame row in Pandas where column value in list
  • Python Integer and String Using
  • Python requests: URL with percent character
  • Why ActionChains(driver).move_to_element(elem).click().perform() twice
  • Why is my code not compiling
  • How to equalize the size of two numpy arrays
  • Hive Server 2 error on python connect with hiveserver2
  • TypeError: argument 1 must have a "write" method
  • Python, read uart and post to MQTT, has extra spaces
  • test getting skipped in pytest
  • Python: from list to enumerated list to pass to lambda reduce function
  • f[1] raised exception TypeError: 'int' object is not subscriptable
  • how to make a random list in python3
  • Keeping Python from spacing after breaking a line when printing a List
  • Create a temporary table in python to join with a sql table
  • How to update a specific line in a file in python?
  • Google PubSub python client returning StatusCode.UNAVAILABLE
  • Error in regex substring match in a list in python
  • Pandas groupby() on one column and then sum on another
  • How to use multiple "or" in python code
  • spider = cls(*args, **kwargs) TypeError: __init__() got an unexpected keyword argument '_job'
  • Python, Django LDAP: detecting Authentication failed reasoning
  • Is it good to define a function in a function python
  • Zeep : Need to convert this sample soap request
  • How to render a template and send a file simultaneously with flask
  • Create new column in dataframe with match values from other dataframe
  • Group the values using one column and return the one having max value in other column using pandas dataframe
  • Python3 tkinter analog gauge
  • How to display all the data which is groupby "Cause" from 1981 to 1992 in python pandas?
  • Scrape content in json format - Python
  • How to replace pandas columns with the same name in to another dataframe?
  • Trying to build a proxy with aiohttp
  • Compound interest calculator loops
  • how to create a raw string when it's last character is a `\` in python
  • Scrapy - how can I split the data in this table?
  • Making post requests in python
  • How can I manipulate shapes (colors) in PowerPoint using Python and win32com.client?
  • Get sorted output for os.walk()
  • Pandas Mapping Column
  • How to remove border of microsoft word in text image in opencv with python?
  • why not always use map if its faster than the rest (list comprehension, loop (various variants))?
  • Trying to download a directory with requests
  • Django Django model “doesn't declare an explicit app_label” because of project's init.py file
  • Comparing 2 arrays using numpy and allocating values to a third array
  • How to do change the recieved SQL output format, in python
  • Python: how to write binary data to the stdout so that bash script can use process substitution?
  • How to combine two lists to get a new list of the shape as mentioned in description
  • Run-time Complexity for two algorithms (Big O notation calculation)
  • jupyter SSL: WRONG_VERSION_NUMBER
  • Import of csv data rows and columns when specyfing delimiter
  • Error in texting automated message in whatsapp using python
  • Why my model work ok with test data from train_test_split while doesn't with the new data?
  • Python Networkx: How to "redraw" graph after every iteration?
  • How to read a large json in pandas?
  • Protobuf Message Constructor
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com