|
Java example source code file (ScoreIterationListener.java)
The ScoreIterationListener.java Java example source code/* * * * 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; private long iterCount = 0; /** * @param printIterations frequency with which to print scores (i.e., every printIterations parameter updates) */ public ScoreIterationListener(int printIterations) { this.printIterations = printIterations; } /** Default constructor printing every 10 iterations */ 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(iterCount % printIterations == 0) { invoke(); double result = model.score(); log.info("Score at iteration " + iterCount + " is " + result); } iterCount++; } } Other Java examples (source code examples)Here is a short list of links related to this Java ScoreIterationListener.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.