Questions tagged [tensorflow-estimator]

TensorFlow's tf.estimator module is a high-level machine learning API. It makes it easy to create, train and evaluate models in TensorFlow. You can use predefined models to quickly configure common model types, or create your own custom Estimator.

tensorflow-estimator
Filter by
Sorted by
Tagged with
60 votes
2 answers
18k views

What's the difference between a Tensorflow Keras Model and Estimator?

Both Tensorflow Keras models and Tensorflow Estimators are able to train neural network models and use them to predict new data. They are both high-level APIs that sits on top of the low-level core ...
d4nyll's user avatar
  • 12.2k
44 votes
7 answers
100k views

Tensorflow : logits and labels must have the same first dimension

I am new in tensoflow and I want to adapt the MNIST tutorial https://www.tensorflow.org/tutorials/layers with my own data (images of 40x40). This is my model function : def cnn_model_fn(features, ...
Geoffrey Pruvost's user avatar
40 votes
1 answer
1k views

How to create only one copy of graph in tensorboard events file with custom tf.Estimator?

I'm using a custom tf. Estimator object to train a neural network. The problem is in the size of the events file after training - it is unreasonably large. I've already solved the problem with saving ...
Andrii Zadaianchuk's user avatar
33 votes
8 answers
51k views

ModuleNotFoundError: No module named 'tensorflow_core.estimator' for tensorflow 2.1.0

When using tensorflow, I have the following error messages ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.' File "<frozen importlib....
user297850's user avatar
  • 7,855
25 votes
1 answer
2k views

Graph optimizations on a tensorflow serveable created using tf.Estimator

Context: I have a simple classifier based on tf.estimator.DNNClassifier that takes text and output probabilities over an intent tags. I am able to train an export the model to a serveable as well as ...
o-90's user avatar
  • 17.3k
22 votes
4 answers
13k views

Early stopping with tf.estimator, how?

I'm using tf.estimator in TensorFlow 1.4 and tf.estimator.train_and_evaluate is great but I need early stopping. What's the prefered way of adding that? I assume there is some tf.train.SessionRunHook ...
Carl Thomé's user avatar
  • 2,722
20 votes
3 answers
4k views

TensorFlow Estimator ServingInputReceiver features vs receiver_tensors: when and why?

In a previous question the purpose and structure of the serving_input_receiver_fn is explored and in the answer: def serving_input_receiver_fn(): """For the sake of the example, let's assume your ...
SumNeuron's user avatar
  • 5,018
19 votes
2 answers
1k views

How to inform class weights when using `tensorflow.python.keras.estimator.model_to_estimator` to convert Keras Models to Estimator API?

I'm having some trouble to convert a pure Keras model to TensorFlow Estimator API on an unbalanced dataset. When using pure Keras API, the class_weight parameter is available at model.fit method, but ...
Rodrigo Pereira's user avatar
17 votes
2 answers
6k views

Transfer learning with tf.estimator.Estimator framework

I'm trying to do transfer learning of an Inception-resnet v2 model pretrained on imagenet, using my own dataset and classes. My original codebase was a modification of a tf.slim sample which I can't ...
GPhilo's user avatar
  • 18.9k
16 votes
1 answer
2k views

What does google cloud ml-engine do when a Json request contains "_bytes" or "b64"?

The google cloud documentation (see Binary data in prediction input) states: Your encoded string must be formatted as a JSON object with a single key named b64. The following Python example ...
NickDGreg's user avatar
  • 485
14 votes
2 answers
4k views

Tensorflow 2.0 Keras is training 4x slower than 2.0 Estimator

We recently switched to Keras for TF 2.0, but when we compared it to the DNNClassifier Estimator on 2.0, we experienced around 4x slower speeds with Keras. But I cannot for the life of me figure out ...
Byest's user avatar
  • 337
12 votes
2 answers
7k views

Log accuracy metric while training a tf.estimator

What's the simplest way to print accuracy metrics along with the loss when training a pre-canned estimator? Most tutorials and documentations seem to address the issue of when you're creating a ...
viksit's user avatar
  • 7,622
12 votes
1 answer
4k views

Tensorflow Estimator - warm_start_from and model_dir

When using tf.estimator with warm_start_from and model_dir, and both warm_start_from directory and model_dir directory contain valid checkpoints, which checkpoint will be actually restored? To give ...
mtngld's user avatar
  • 567
11 votes
3 answers
37k views

Tensorflow==2.0.0a0 - AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer'

I'm using Tensorflow==2.0.0a0 and want to run the following script: import tensorflow as tf import tensorboard import pandas as pd import matplotlib.pyplot as plt import numpy as np import ...
razimbres's user avatar
  • 4,916
11 votes
2 answers
6k views

Module 'tensorflow.tools.docs.doc_controls' has no attribute 'inheritable_header'

Running estimator from tensorflow today and came up with this error, any idea how to solve it? File "C:\Users\ASUS Laptop\anaconda3\envs\tf_gpu\lib\site-packages\tensorflow_estimator\python\...
簡亞倫's user avatar
  • 121
11 votes
2 answers
12k views

What does DNN mean in a TensorFlow Estimator.DNNClassifier?

I'm guessing that DNN in the sense used in TensorFlow means "deep neural network". But I find this deeply confusing since the notion of a "deep" neural network seems to be in wide use elsewhere to ...
omatai's user avatar
  • 3,597
11 votes
1 answer
2k views

Run prediction from saved model in tensorflow 2.0

I have a saved model (a directory with model.pd and variables) and wanted to run predictions on a pandas data frame. I've unsuccessfully tried a few ways to do this: Attempt 1: Restore the estimator ...
figlio perduto's user avatar
10 votes
1 answer
5k views

How to use tf.data's initializable iterators within a tf.estimator's input_fn?

I would like to manage my training with a tf.estimator.Estimator but have some trouble to use it alongside the tf.data API. I have something like this: def model_fn(features, labels, params, mode): ...
guillaumekln's user avatar
10 votes
1 answer
4k views

How to use tensorflow debugging tool tfdbg on tf.estimator in Tensorflow?

I am working with Tensorflow version 1.4, and I want to debug my train() function. In this link https://www.tensorflow.org/programmers_guide/debugger#debugging_tf-learn_estimators_and_experiments ...
Benjamin Larrousse's user avatar
10 votes
4 answers
9k views

Prediction from model saved with `tf.estimator.Estimator` in Tensorflow

I am using tf.estimator.Estimator to train a model: def model_fn(features, labels, mode, params, config): input_image = features["input_image"] eval_metric_ops = {} predictions = {} ...
hadim's user avatar
  • 646
9 votes
2 answers
10k views

MirroredStrategy doesn't use GPUs

I wanted to use the tf.contrib.distribute.MirroredStrategy() on my Multi GPU System but it doesn't use the GPUs for the training (see the output below). Also I am running tensorflow-gpu 1.12. I did ...
craft's user avatar
  • 525
9 votes
2 answers
5k views

Tensorflow estimator: average_loss vs loss

In tf.estimator, what's the difference between average_loss and loss? I would have guessed from the names that the former would be the latter divided by the number of records, but that's not the case; ...
rwallace's user avatar
  • 32.4k
9 votes
2 answers
3k views

How to control frequency of loss logging messages when using tf.Estimator

I'm using TF 1.4. My question is about tf.estimator.Estimator. I'd like to control the frequency of the "loss and step" Info messages, like: INFO:tensorflow:loss = 0.00896569, step = 14901 (14.937 ...
Michael Rubinstein's user avatar
9 votes
4 answers
11k views

How to fix "module 'tensorflow' has no attribute 'estimator' " error

I'm using conda (env created via YAML) + pip to set up a Tensorflow v1.13.1 environment on my Linux Mint box. After setup, whenever I try to import tf.estimator I receive the AttributeError described ...
cjs's user avatar
  • 300
9 votes
2 answers
739 views

Can't use estimator + dataset and train for less than one epoch

TensorFlow 1.4 moves TF Dataset to core (tf.data.Dataset) and doc/tutorial suggest to use tf.estimator to train models. However, as recommended at the end of this page, the Dataset object and its ...
nisace's user avatar
  • 463
9 votes
0 answers
959 views

Tensorflow: Integrate Keras Model in Estimator model_fn

I am working on the problem of using a pretrained keras.applications model in the model_fn of a estimator. In my research group, we are using Tensorflow estimator since they offer many advantages ...
Simon's user avatar
  • 398
9 votes
2 answers
1k views

Tensorflow DNNclassifier: error wile training (numpy.ndarray has no attribute index)

I am trying to train a DNNClassifier in tensorflow Here is my code train_input_fn = tf.estimator.inputs.pandas_input_fn( x=X_train, y=y_train, batch_size=1000, shuffle = True ) ...
Cybercop's user avatar
  • 8,620
9 votes
2 answers
3k views

Tensorflow Estimator predict is slow

I have trained a tf.estimator.LinearClassifier. While training and evaluating the model takes a reasonable amount of time for my data size (~60 sec), predicting takes many order of magnitude longer (~...
Stephan Goulet's user avatar
8 votes
2 answers
22k views

Could not find matching function to call loaded from the SavedModel

I wrote below code and it suppose to load a model followed by a predictive run of an element from MNIST dataset. At the beginning of the execution the code works fine and I get my desired prediction, ...
Abdellatif Hannachi's user avatar
8 votes
1 answer
2k views

How to switch between training and validation dataset with tf.MonitoredTrainingSession?

I want to use feedable iterator design in tensorflow Dataset API, so I can switch to validation data after some training steps. But if I switched to validation data, it will end the whole session. ...
Xiang Zhang's user avatar
  • 2,863
8 votes
3 answers
9k views

Tensorflow - How to use the GPU instead of a CPU for tf.Estimator() CNNs

I think it was supposed to be used with with tf.device("/gpu:0"), but where do I put it? I don't think it's: with tf.device("/gpu:0"): tf.app.run() So should I put it in the main() function of ...
Gensoukyou1337's user avatar
7 votes
4 answers
4k views

Is it possible to restore a tensorflow estimator from saved model?

I use tf.estimator.train_and_evaluate() to train my custom estimator. My dataset is partitioned 8:1:1 for training, evaluation and test. At the end of the training, I would like to restore the best ...
Taro Kiritani's user avatar
7 votes
1 answer
6k views

Input multiple files into Tensorflow dataset

I have the following input_fn. def input_fn(filenames, batch_size): # Create a dataset containing the text lines. dataset = tf.data.TextLineDataset(filenames).skip(1) # Parse each line. ...
user2725109's user avatar
  • 2,336
7 votes
1 answer
2k views

TensorFlow Custom Estimator - Restore model after small changes in model_fn

I am using tf.estimator.Estimator for developing my model, I wrote a model_fn and trained 50,000 iterations, now I want to make a small change in my model_fn, for example add a new layer. I don't ...
mtngld's user avatar
  • 567
7 votes
1 answer
5k views

How to augment data in tensorflow tfrecords?

I am storing my data using tfrecords and I read them as tensors using Dataset API and then I use the Estimator API to perform training. Now, I want to do online data-augmentation on each item in the ...
deep_jandu's user avatar
7 votes
1 answer
1k views

Advantage of using experiments in TensorFlow

Many of TensorFlow's example applications create Experiments and run one of the Experiment's methods by calling tf.contrib.data.learn_runner.run. It looks like an Experiment is essentially a wrapper ...
MatthewScarpino's user avatar
7 votes
1 answer
663 views

When to use an iterator in Tensorflow Estimator

In the Tensorflow guides there are two separate places where the guide describes the input function for the Iris Data example. One input function returns just the dataset itself, while the other ...
D Myers's user avatar
  • 73
7 votes
1 answer
771 views

Tensorflow 1.10 TFRecordDataset - recovering TFRecords

Notes: this question extends upon a previous question of mine. In that question I ask about the best way to store some dummy data as Example and SequenceExample seeking to know which is better for ...
SumNeuron's user avatar
  • 5,018
7 votes
2 answers
1k views

Why does the TensorFlow Estimator API take inputs as a lambda?

The tf.estimator API takes input "input functions" that return Datasets. For example, Estimator.train() takes an input_fn (documentation). In the examples I've seen, whenever this function is ...
jkff's user avatar
  • 17.8k
7 votes
1 answer
1k views

Loading trained Tensorflow model into estimator

Say that I have trained a Tensorflow Estimator: estimator = tf.contrib.learn.Estimator( model_fn=model_fn, model_dir=MODEL_DIR, config=some_config) And I fit it to some train data: estimator....
Guido's user avatar
  • 6,492
6 votes
1 answer
3k views

TensorFlow 1.10+ custom estimator early stopping with train_and_evaluate

Suppose you are training a custom tf.estimator.Estimator with tf.estimator.train_and_evaluate using a validation dataset in a setup similar to that of @simlmx's: classifier = tf.estimator.Estimator( ...
SumNeuron's user avatar
  • 5,018
6 votes
1 answer
10k views

Tensorflow error : unsupported callable

I follow the tutorial https://www.tensorflow.org/tutorials/layers and I want use it to use my own dataset. def train_input_fn_custom(filenames_array, labels_array, batch_size): # Reads an image ...
Geoffrey Pruvost's user avatar
6 votes
2 answers
10k views

Automatically save Tensorboard-like plot of loss to image file

I am currently trying to predict the movement of a particle using a tensorflow premade Estimator (tf.estimator.DNNRegressor). I want to save an image of the average loss plot, like the one ...
Strandtasche's user avatar
6 votes
1 answer
2k views

tensors are from different graphs

I am new to tensorflow. Trying to create an input pipeline from tfrecords. Below is my code snippet to create batches and feed into my estimator : def generate_input_fn(image,label,batch_size=...
Pratik Kumar's user avatar
  • 2,231
6 votes
1 answer
2k views

How to run estimator.train without saving checkpoints

I'm looking for a way to implement a search of learning rate as described here: https://arxiv.org/pdf/1506.01186.pdf . My network is implemented using estimator api and I'd like to stick to that, but ...
Piotr Czapla's user avatar
  • 26.1k
6 votes
3 answers
4k views

Using the Tensorflow profiler with tf.Estimator

I need to use the Tensorflow profiler to profile some code that is running slowly for some reason. Unfortunately, the code in question uses tf.Estimator, so I can't figure out how to inject the run ...
forefinger's user avatar
  • 3,817
6 votes
2 answers
7k views

Custom eval_metric_ops in Estimator in Tensorflow

I am trying to add the r squared in the eval_metric_ops in my estimator like this: def model_fn(features, labels, mode, params): predict = prediction(features, params, mode) loss = my_loss_fn ...
Nicolas REY's user avatar
6 votes
1 answer
902 views

Using Tensorflow Datasets and Estimators with More Data than Ram

I've recently switched my modeling framework to use custom Tensorflow Estimators and Datasets, and am quite happy overall with this workflow. However, I've just noticed an issue with how my ...
Stephen W.'s user avatar
6 votes
1 answer
760 views

Tensorflow MNIST Estimator: batch size affects the graph expected input?

I have followed the TensorFlow MNIST Estimator tutorial and I have trained my MNIST model. It seems to work fine, but if I visualize it on Tensorboard I see something weird: the input shape that the ...
Andrea Rossi's user avatar
  • 1,001
6 votes
3 answers
5k views

Correct payload for TensorFlow Serving REST API

I have converted a Keras model to a Tensorflow estimator, added Tensorflow Transform to the graph and then exported the model for serving. When I check the model signature, I can see the following ...
neurix's user avatar
  • 4,226

1
2 3 4 5
14