tensorflow-estimator

Question on Tensorflow Estimator practices, should Tensorflow Operations be conducted in `my_model`, or elsewhere?

别来无恙 提交于 2020-01-25 09:23:06
问题 I am getting an error when I try to convert my model to use a Tensorflow Estimator, and it think it's due to my_model not having an active session in place. So should Tensorflow operations be conducted outside of my_model ? For example, I am getting an error by the way I currently define it: def my_model( features, labels, mode, params): train_dataset = features train_labels = labels batch_sizeE=params["batch_size"] embedding_sizeE=params["embedding_size"] num_inputsE=params["num_inputs"] num

Tensorflow Estimator - High evaluation values on training data

别等时光非礼了梦想. 提交于 2020-01-25 07:53:07
问题 I'm using Tensorflow 1.10 with a custom Estimator. To test my training/evaluation loop, I just feed the same image/label into the network every time, so I expected the network to converge fast, which it does. I'm also using the same image for evaluation, but get a much bigger loss value than when training. After training 2000 steps the loss is: INFO:tensorflow:Loss for final step: 0.01181452 but evaluates to: Eval loss at step 2000: 0.41252694 This seems wrong to me. It looks like the same

Distributed Tensorflow Estimator execution does not trigger evaluation or export

徘徊边缘 提交于 2020-01-23 04:06:46
问题 I am testing distributed training with tensorflow Estimators. In my example I fit a simple sinus function with a custom estimator using tf.estimator.train_and_evaluation. After training and evaluation I want to export the model to have it ready for tensorflow serving. However the evaluation and export is only triggered when executing the estimator in non-distributed way. The model and Estimators are defined as follows: def my_model(features, labels, mode): # define simple dense network net =

Distributed Tensorflow Estimator execution does not trigger evaluation or export

喜夏-厌秋 提交于 2020-01-23 04:06:14
问题 I am testing distributed training with tensorflow Estimators. In my example I fit a simple sinus function with a custom estimator using tf.estimator.train_and_evaluation. After training and evaluation I want to export the model to have it ready for tensorflow serving. However the evaluation and export is only triggered when executing the estimator in non-distributed way. The model and Estimators are defined as follows: def my_model(features, labels, mode): # define simple dense network net =

TensorFlow Serving crossed columns strange error

核能气质少年 提交于 2020-01-16 09:13:07
问题 I am receiving the following error when trying to send a prediction request to my saved model, running with TensorFlow Serving: { "error": "Expected D2 of index to be 2 got 3 at position 0\n\t [[{{node linear/linear_model/linear_model/linear_model/int2Id_X_stringId/SparseCross}}]]" } The problem appears to come from trying to use crossed columns in a linear model...? My model in service is a tf.estimator.LinearClassifier . My REST API request is a POST to 'model_directory/model:predict' with

Train Tensorflow model with estimator (from_generator)

空扰寡人 提交于 2020-01-13 02:23:11
问题 I am trying train an estimator with a generator, but I want to feed this estimator with a package of samples for each iteration. I show the code: def _generator(): for i in range(100): feats = np.random.rand(4,2) labels = np.random.rand(4,1) yield feats, labels def input_func_gen(): shapes = ((4,2),(4,1)) dataset = tf.data.Dataset.from_generator(generator=_generator, output_types=(tf.float32, tf.float32), output_shapes=shapes) dataset = dataset.batch(4) # dataset = dataset.repeat(20) iterator

Unable to use canned Tensorflow RNN Estimator

可紊 提交于 2020-01-06 05:45:06
问题 I am trying to use the canned RNN Estimator from Tensorflow as follows: import tensorflow as tf sequence_feature_colums = [tf.contrib.feature_column.sequence_numeric_column("test")] estimator = tf.contrib.estimator.RNNEstimator( head=tf.contrib.estimator.regression_head(), sequence_feature_columns=sequence_feature_colums) def input_fn_train(): dataset = tf.data.Dataset.from_tensor_slices(({"test": [0]}, [0])) dataset = dataset.batch(1) return dataset estimator.train(input_fn=input_fn_train,

How to deal with triplet loss when at time of input i have only two files i.e. at time of testing

拜拜、爱过 提交于 2020-01-06 04:41:05
问题 I am implementing a siamese network in which i know how to calculate triplet loss by picking anchor, positive and negative by dividing input in three parts(which is a handcrafted feature vector) and then calculating it at time of training. anchor_output = ... # shape [None, 128] positive_output = ... # shape [None, 128] negative_output = ... # shape [None, 128] d_pos = tf.reduce_sum(tf.square(anchor_output - positive_output), 1) d_neg = tf.reduce_sum(tf.square(anchor_output - negative_output)

TF Estimator: Can't Load *.pb from Saved Model

怎甘沉沦 提交于 2020-01-05 05:53:19
问题 I create a simple model using TF Estimator and save the model using export_savedmodel function. I use a simple Iris dataset which has 4 features. num_epoch = 50 num_train = 120 num_test = 30 # 1 Define input function def input_function(x, y, is_train): dict_x = { "thisisinput" : x, } dataset = tf.data.Dataset.from_tensor_slices(( dict_x, y )) if is_train: dataset = dataset.shuffle(num_train).repeat(num_epoch).batch(num_train) else: dataset = dataset.batch(num_test) return dataset def my

How to run estimator.train without saving checkpoints

安稳与你 提交于 2020-01-03 11:32:38
问题 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 unfortunately I'm not able to force estimator to skip saving checkpoints. Do you know a way to simply run a one epoch o training without saving the checkpoints? 回答1: According to the docs tf.estimator.RunConfig: If both save_checkpoints_steps and save_checkpoints_secs are None, then checkpoints