0

I would like to use SKFLOW to step through the fit of a DNNClassifier, unfortunately code such as:

    step_classifier = skflow.DNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
    for _ in range(50):
      step_classifier = step_classifier.partial_fit(X, Y, steps =1 ,batch_size=32)
      score = metrics.accuracy_score(y, step_classifier.predict(x))
      print("Accuracy: %f" % score)

does not produce the desired result -- each iteration of the fit provides the same accuracy:

   Accuracy: 0.315789
     Accuracy: 0.315789
     Accuracy: 0.315789
     Accuracy: 0.315789
   etc

It seems in previous versions on this DNNClassifier ie TensorFlowDNNClassifier there was continue_training flag that would produce the desired effect. This is not available in DNNClassifier. So how is per epoch stepwise training correctly implemented in SKFLOW? Thank you

Rob Umbra
  • 1
  • 3

1 Answers1

1

I hope this answer will be helpful though it is a little late.
The line :
step_classifier = step_classifier.partial_fit(X, Y, steps =1 ,batch_size=32)
Has as argument steps = 1. And you use an outer loop calling several times this line. I suspect that each time this line is called, an iterator mini batch of size 32 is created and iterates through your data for every step, starting from the first example. In other words, since you left steps =1, I suspect you are training your decision model only on the same 32 first training examples, because every time you call step_classifier.partial_fit the iterator starts from the first training example. Try replacing steps = 1 with steps = 100 for example.

As for epochs, I am myself trying to find a way... well for now just take the value steps = Ceiling(dataset size / mini batch size) * desiredEpochs until we find an alternative