home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (PlotFiltersIterationListener.java)

This example Java source code file (PlotFiltersIterationListener.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

awt, bufferedimage, file, image, imageio, indarray, ioexception, list, override, plotfiltersiterationlistener, util

The PlotFiltersIterationListener.java Java example source code

package org.deeplearning4j.plot.iterationlistener;

import org.canova.image.loader.ImageLoader;
import org.deeplearning4j.nn.api.Model;
import org.deeplearning4j.optimize.api.IterationListener;
import org.deeplearning4j.plot.PlotFilters;
import org.nd4j.linalg.api.ndarray.INDArray;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;

 * @author Adam Gibson
public class PlotFiltersIterationListener implements IterationListener {
    private List<String> variables;
    private int iteration = 1;
    private  PlotFilters filters;
    private File outputFile = new File("render.png");

    public PlotFiltersIterationListener(PlotFilters plotFilters,List<String> variables, int iteration) {
        this.filters = plotFilters;
        this.variables = variables;
        this.iteration = iteration;

    public List<String> getVariables() {
        return variables;

    public void setVariables(List<String> variables) {
        this.variables = variables;

    public int getIteration() {
        return iteration;

    public void setIteration(int iteration) {
        this.iteration = iteration;

    public PlotFilters getFilters() {
        return filters;

    public void setFilters(PlotFilters filters) {
        this.filters = filters;

    public File getOutputFile() {
        return outputFile;

    public void setOutputFile(File outputFile) {
        this.outputFile = outputFile;

    public boolean invoked() {
        return false;

    public void invoke() {


    public void iterationDone(Model model, int iteration) {
        if(this.iteration > 0 && iteration % this.iteration == 0) {
            INDArray weights = model.getParam(variables.get(0));
            INDArray plot = filters.getPlot();
            BufferedImage image = ImageLoader.toImage(plot);
            try {
                ImageIO.write(image, "png", outputFile);
            } catch (IOException e) {

Other Java examples (source code examples)

Here is a short list of links related to this Java PlotFiltersIterationListener.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 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.