alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (EmbeddingLayer.java)

This example Java source code file (EmbeddingLayer.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

allargsconstructor, builder, data, embeddinglayer, equalsandhashcode, feedforwardlayer, noargsconstructor, override, suppresswarnings, tostring

The EmbeddingLayer.java Java example source code

package org.deeplearning4j.nn.conf.layers;

import lombok.*;

/**Embedding layer: feed-forward layer that expects single integers per example as input (class numbers, in range 0 to numClass-1)
 * as input. This input has shape [numExamples,1] instead of [numExamples,numClasses] for the equivalent one-hot representation.
 * Mathematically, EmbeddingLayer is equivalent to using a DenseLayer with a one-hot representation for the input; however,
 * it can be much more efficient with a large number of classes (as a dense layer + one-hot input does a matrix multiply
 * with all but one value being zero).<br>
 * <b>Note: can only be used as the first layer for a network
* <b>Note 2: For a given example index i, the output is activationFunction(weights.getRow(i) + bias), hence the * weight rows can be considered a vector/embedding for each example. * @author Alex Black */ @Data @NoArgsConstructor @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) public class EmbeddingLayer extends FeedForwardLayer { private EmbeddingLayer(Builder builder){ super(builder); } @AllArgsConstructor public static class Builder extends FeedForwardLayer.Builder<Builder> { @Override @SuppressWarnings("unchecked") public EmbeddingLayer build(){ return new EmbeddingLayer(this); } } }

Other Java examples (source code examples)

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

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.