1# Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""`Trainable` interface (deprecated). 16 17This module and all its submodules are deprecated. See 18[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md) 19for migration instructions. 20""" 21 22from __future__ import absolute_import 23from __future__ import division 24from __future__ import print_function 25 26import abc 27 28import six 29 30 31@six.add_metaclass(abc.ABCMeta) 32class Trainable(object): 33 """Interface for objects that are trainable by, e.g., `Experiment`. 34 35 THIS CLASS IS DEPRECATED. 36 """ 37 38 @abc.abstractmethod 39 def fit(self, 40 x=None, 41 y=None, 42 input_fn=None, 43 steps=None, 44 batch_size=None, 45 monitors=None, 46 max_steps=None): 47 """Trains a model given training data `x` predictions and `y` labels. 48 49 Args: 50 x: Matrix of shape [n_samples, n_features...] or the dictionary of 51 Matrices. 52 Can be iterator that returns arrays of features or dictionary of arrays 53 of features. 54 The training input samples for fitting the model. If set, `input_fn` 55 must be `None`. 56 y: Vector or matrix [n_samples] or [n_samples, n_outputs] or the 57 dictionary of same. 58 Can be iterator that returns array of labels or dictionary of array of 59 labels. 60 The training label values (class labels in classification, real numbers 61 in regression). 62 If set, `input_fn` must be `None`. Note: For classification, label 63 values must 64 be integers representing the class index (i.e. values from 0 to 65 n_classes-1). 66 input_fn: Input function returning a tuple of: 67 features - `Tensor` or dictionary of string feature name to `Tensor`. 68 labels - `Tensor` or dictionary of `Tensor` with labels. 69 If input_fn is set, `x`, `y`, and `batch_size` must be `None`. 70 steps: Number of steps for which to train model. If `None`, train forever. 71 'steps' works incrementally. If you call two times fit(steps=10) then 72 training occurs in total 20 steps. If you don't want to have incremental 73 behavior please set `max_steps` instead. If set, `max_steps` must be 74 `None`. 75 batch_size: minibatch size to use on the input, defaults to first 76 dimension of `x`. Must be `None` if `input_fn` is provided. 77 monitors: List of `BaseMonitor` subclass instances. Used for callbacks 78 inside the training loop. 79 max_steps: Number of total steps for which to train model. If `None`, 80 train forever. If set, `steps` must be `None`. 81 82 Two calls to `fit(steps=100)` means 200 training 83 iterations. On the other hand, two calls to `fit(max_steps=100)` means 84 that the second call will not do any iteration since first call did 85 all 100 steps. 86 87 Returns: 88 `self`, for chaining. 89 """ 90 raise NotImplementedError 91