2017-02-25 15 views
6

नोट: यहां मेरा पहला प्रश्न। विवरण या जानकारी की कमी के लिए क्षमा करें। यदि आवश्यक हो तो स्पष्ट करने के लिए खुश से अधिक।टेंसरफ्लो: एसकेकॉमपेट मूल्यह्रास चेतावनी

मैं मैक पर TensorFlow 1.0.0 चल रहा हूँ और जब learn.Estimator वर्ग

WARNING:tensorflow:From :25: calling fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and will be removed after 2016-12-01. Instructions for updating: Estimator is decoupled from Scikit Learn interface by moving into separate class SKCompat. Arguments x, y and batch_size are only available in the SKCompat class, Estimator will only accept input_fn. Example conversion: est = Estimator(...) -> est = SKCompat(Estimator(...))

मैं इस वर्ग को देख कोशिश की है का उपयोग करते हुए मैं इस चेतावनी बार आ रही है और वहाँ के संबंध में शून्य जानकारी है यह। पूर्ण कोड यहाँ पोस्ट किया जाता है

https://github.com/austinmwhaley/DeepFarm/blob/master/prototype_1.ipynb

कृपया मुझे बताएं कि क्या कोई अन्य जानकारी किसी को भी जरूरत है कि

+3

[cnn_mnist ट्यूटोरियल] (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/layers/cnn_mnist.py) का पालन करते समय मेरे पास समान समस्या है। त्रुटि जानकारी के आधार पर, मैंने 'tensorflow.contrib.learn.SKCompat आयात SKCompat' से कुछ करने की कोशिश की और उन्हें 'SKCompat() 'के साथ अनुमानक को लपेटें। लेकिन यह काम नहीं करता है ... त्रुटि: "कोई मॉड्यूल SKCompat नाम नहीं है"। कुछ मदद की ज़रूरत है! – user3768495

उत्तर

5

आप tensorflow.contrib.learn.python से SKCompat आयात कर सकते हैं करते हैं:

from tensorflow.contrib.learn.python import SKCompat 

और फिर अपने अनुमानक को SKCompat() उदाहरण के साथ लपेटें इस तरह:

classifier = SKCompat(tf.contrib.learn.LinearClassifier(args)) 
3

या आप बस updated Estimator API of TensorFlow r1.1

मॉडल परिभाषा के लिए एपीआई का उपयोग पैरामीटर, वापसी प्रकार या केवल समारोह के नाम पर कुछ छोटे परिवर्तन के साथ काफी समान है। यहाँ एक उदाहरण है कि मैं का इस्तेमाल किया है है:

def model_fn(): 
    def _build_model(features, labels, mode, params): 
     # 1. Configure the model via TensorFlow operations 
     # Connect the first hidden layer to input layer (features) with relu activation 
     y = tf.contrib.layers.fully_connected(features, num_outputs=64, activation_fn=tf.nn.relu, 
               weights_initializer=tf.contrib.layers.xavier_initializer()) 
     y = tf.contrib.layers.fully_connected(y, num_outputs=64, activation_fn=tf.nn.relu, 
               weights_initializer=tf.contrib.layers.xavier_initializer()) 
     y = tf.contrib.layers.fully_connected(y, num_outputs=1, activation_fn=tf.nn.sigmoid, 
               weights_initializer=tf.contrib.layers.xavier_initializer()) 

     predictions = y 

     # 2. Define the loss function for training/evaluation 
     if mode == tf.estimator.ModeKeys.TRAIN or mode == tf.estimator.ModeKeys.EVAL: 
      loss = tf.reduce_mean((predictions - labels) ** 2) 
     else: 
      loss = None 

     if mode != tf.estimator.ModeKeys.PREDICT: 
      eval_metric_ops = { 
       "rmse": tf.metrics.root_mean_squared_error(tf.cast(labels, tf.float32), predictions), 
       "accuracy": tf.metrics.accuracy(tf.cast(labels, tf.float32), predictions), 
       "precision": tf.metrics.precision(tf.cast(labels, tf.float32), predictions) 
      } 
     else: 
      eval_metric_ops = None 

     # 3. Define the training operation/optimizer 
     if mode == tf.estimator.ModeKeys.TRAIN: 
      train_op = tf.contrib.layers.optimize_loss(
       loss=loss, 
       global_step=tf.contrib.framework.get_global_step(), 
       learning_rate=0.001, 
       optimizer="Adam") 
     else: 
      train_op = None 

     if mode == tf.estimator.ModeKeys.PREDICT: 
      predictions_dict = {"pred": predictions} 
     else: 
      predictions_dict = None 

     # 5. Return predictions/loss/train_op/eval_metric_ops in ModelFnOps object 
     return tf.estimator.EstimatorSpec(mode=mode, 
              predictions=predictions_dict, 
              loss=loss, 
              train_op=train_op, 
              eval_metric_ops=eval_metric_ops) 
    return _build_model 

और तुम इस तरह तो इस मॉडल का उपयोग कर सकते हैं:

e = tf.estimator.Estimator(model_fn=model_fn(), params=None) 
e.train(input_fn=input_fn(), steps=1000) 

TensorFlow r1.1 के लिए एक इनपुट-समारोह का एक उदाहरण में पाया जा सकता मेरी उत्तर here

संबंधित मुद्दे