Home | History | Annotate | Download | only in models
      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 """A model that places a decision tree embedding before a neural net."""
     16 from __future__ import absolute_import
     17 from __future__ import division
     18 from __future__ import print_function
     19 
     20 from tensorflow.contrib.tensor_forest.hybrid.python import hybrid_model
     21 from tensorflow.contrib.tensor_forest.hybrid.python.layers import decisions_to_data
     22 from tensorflow.contrib.tensor_forest.hybrid.python.layers import fully_connected
     23 from tensorflow.python.training import adagrad
     24 
     25 
     26 class DecisionsToDataThenNN(hybrid_model.HybridModel):
     27   """A model that places a decision tree embedding before a neural net."""
     28 
     29   def __init__(self,
     30                params,
     31                device_assigner=None,
     32                optimizer_class=adagrad.AdagradOptimizer,
     33                **kwargs):
     34     super(DecisionsToDataThenNN, self).__init__(
     35         params,
     36         device_assigner=device_assigner,
     37         optimizer_class=optimizer_class,
     38         **kwargs)
     39 
     40     self.layers = [decisions_to_data.DecisionsToDataLayer(params,
     41                                                           0, device_assigner),
     42                    fully_connected.FullyConnectedLayer(
     43                        params, 1, device_assigner=device_assigner)]
     44