|
Java example source code file (ConvolutionUtils.java)
The ConvolutionUtils.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.util; import org.deeplearning4j.nn.conf.NeuralNetConfiguration; /** * Convolutional shape utilities * * @author Adam Gibson */ public class ConvolutionUtils { /** * Get the height and width * from the configuration * @param conf the configuration to get height and width from * @return the configuration to get height and width from */ public static int[] getHeightAndWidth(NeuralNetConfiguration conf) { return getHeightAndWidth(((org.deeplearning4j.nn.conf.layers.ConvolutionLayer) conf.getLayer()).getKernelSize()); } /** * @param conf the configuration to get * the number of kernels from * @return the number of kernels/filters to apply */ public static int numFeatureMap(NeuralNetConfiguration conf) { return ((org.deeplearning4j.nn.conf.layers.ConvolutionLayer) conf.getLayer()).getNOut(); } /** * Get the height and width * for an image * @param shape the shape of the image * @return the height and width for the image */ public static int[] getHeightAndWidth(int[] shape) { if(shape.length < 2) throw new IllegalArgumentException("No width and height able to be found: array must be at least length 2"); return new int[] {shape[shape.length - 1],shape[shape.length - 2]}; } /** * Returns the number of * feature maps for a given shape (must be at least 3 dimensions * @param shape the shape to get the * number of feature maps for * @return the number of feature maps * for a particular shape */ public static int numChannels(int[] shape) { if(shape.length < 4) return 1; return shape[1]; } } Other Java examples (source code examples)Here is a short list of links related to this Java ConvolutionUtils.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.