/*
 *
 *  * Copyright 2015 Skymind,Inc.
 *  *
 *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *    you may not use this file except in compliance with the License.
 *  *    You may obtain a copy of the License at
 *  *
 *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    Unless required by applicable law or agreed to in writing, software
 *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *    See the License for the specific language governing permissions and
 *  *    limitations under the License.
 *
 */

package org.deeplearning4j.optimize.listeners;

import org.deeplearning4j.nn.api.Model;
import org.deeplearning4j.optimize.api.IterationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Score iteration listener
 *
 * @author Adam Gibson
 */
public class ScoreIterationListener implements IterationListener {
    private int printIterations = 10;
    private static final Logger log = LoggerFactory.getLogger(ScoreIterationListener.class);
    private boolean invoked = false;

    public ScoreIterationListener(int printIterations) {
        this.printIterations = printIterations;
    }

    public ScoreIterationListener() {
    }

    @Override
    public boolean invoked(){ return invoked; }

    @Override
    public void invoke() { this.invoked = true; }

    @Override
    public void iterationDone(Model model, int iteration) {
        if(printIterations <= 0)
            printIterations = 1;
        if(iteration % printIterations == 0) {
            invoke();
            double result = model.score();
            log.info("Score at iteration " + iteration + " is " + result);

        }

    }
}

@@ -1163,16 +1163,182 @@
  false;%0A
+    private long iterCount = 0;%0A%0A    /**%0A     * @param printIterations    frequency with which to print scores (i.e., every printIterations parameter updates)%0A     */
 %0A    pub
@@ -1438,24 +1438,84 @@
 ons;%0A    %7D%0A%0A
+    /** Default constructor printing every 10 iterations */%0A
     public S
@@ -1830,21 +1830,21 @@
  if(iter
-ation
+Count
  %25 print
@@ -1976,21 +1976,21 @@
 %22 + iter
-ation
+Count
  + %22 is 
@@ -2002,17 +2002,16 @@
 esult);%0A
-%0A
         
@@ -2008,21 +2008,41 @@
 ;%0A        %7D%0A
+        iterCount++;
 %0A    %7D%0A%7D%0A

Switch score iteration listener to printing every N total iterations