def testFromContribEstimatorWithSessionConfig(self): estimator = testing_common.get_arithmetic_estimator(core=False) input_fn = testing_common.get_arithmetic_input_fn(core=False) predictor_factories.from_contrib_estimator( estimator, input_fn, output_alternative_key='sum', config=config_pb2.ConfigProto())
def testFromContribEstimatorWithCoreEstimatorRaises(self): estimator = testing_common.get_arithmetic_estimator(core=True) input_fn = testing_common.get_arithmetic_input_fn(core=True) with self.assertRaises(TypeError): predictor_factories.from_contrib_estimator(estimator, input_fn)
def testFromContribEstimator(self): estimator = testing_common.get_arithmetic_estimator(core=False) input_fn = testing_common.get_arithmetic_input_fn(core=False) predictor_factories.from_contrib_estimator(estimator, input_fn, output_alternative_key='sum')
def prediction_input_fn(): feature_placeholders = { 'wvec': tf.placeholder(tf.float32, [1, 2, 3]), 'dvec': tf.placeholder(tf.float32, [1, 2, 3]), } features = { key: tf.expand_dims(tensor, -1) for key, tensor in feature_placeholders.items() } return tf.contrib.learn.InputFnOps(features, None, feature_placeholders) predictor = from_contrib_estimator(estimator=estimator, prediction_input_fn=prediction_input_fn, output_alternative_key="g_dvec") sess = tf.Session() print(predictor.fetch_tensors) wvec = [[[1, 2, 3], [4, 5, 6]]] dvec = [[[2, 3, 4], [5, 6, 7]]] i = 0 g_wvec = [ [ model.dist(wvec[i][0], wvec[i][1]), model.dist(dvec[i][0], dvec[i][1]) ], ] g_dvec = [ [