deeplearning4j

QLearning network in a custom environment is choosing the same action every time, despite the heavy negative reward

牧云@^-^@ 提交于 2020-12-15 04:35:09
问题 So I plugged QLearningDiscreteDense into a dots and boxes game I made. I created a custom MDP environment for it. The problem is that it chooses action 0 each time, the first time it works but then it's not an available action anymore so it's an illegal move. I give illegal moves a reward of Integer.MIN_VALUE , but it doesn't affect anything. Here's the MDP class: public class testEnv implements MDP<testState, Integer, DiscreteSpace> { final private int maxStep; DiscreteSpace actionSpace =

QLearning network in a custom environment is choosing the same action every time, despite the heavy negative reward

*爱你&永不变心* 提交于 2020-12-15 04:35:06
问题 So I plugged QLearningDiscreteDense into a dots and boxes game I made. I created a custom MDP environment for it. The problem is that it chooses action 0 each time, the first time it works but then it's not an available action anymore so it's an illegal move. I give illegal moves a reward of Integer.MIN_VALUE , but it doesn't affect anything. Here's the MDP class: public class testEnv implements MDP<testState, Integer, DiscreteSpace> { final private int maxStep; DiscreteSpace actionSpace =

Libraries not accessible for “classloader-namespace”, when loading DL4J model using restoreMultiLayerNetwork()

↘锁芯ラ 提交于 2020-02-02 12:09:47
问题 I cannot find out how to get rid of / solve the below errors, that occur when loading a Neural Network model using the DL4J method restoreMultiLayerNetwork using Android API >= 24: The errors occur when the following line within the method restoreMultiLayerNetwork is called: params = Nd4j.read(ins2); with InputStream ins2 = getResources().openRawResource(getResources().getIdentifier("coefficients", "raw", getPackageName())); and "coefficients.bin" is the coefficients file, created by the

Epochs and Iterations in Deeplearning4j

你说的曾经没有我的故事 提交于 2020-01-15 03:21:28
问题 I recently started learning Deeplearning4j and I fail to understand how the concept of epochs and iterations is actually implemented. In the online documentation it says: an epoch is a complete pass through a given dataset ... Not to be confused with an iteration, which is simply one update of the neural net model’s parameters. I ran a training using a MultipleEpochsIterator, but for the first run I set 1 epoch, miniBatchSize = 1 and a dataset of 1000 samples, so I expected the training to

ND4J arrays & their shapes: getting data into a list

风格不统一 提交于 2019-12-24 19:03:46
问题 Consider the following code, which uses the ND4J library to create a simpler version of the "moons" test data set: val n = 100 val n1: Int = n/2 val n2: Int = n-n1 val outerX = Nd4j.getExecutioner.execAndReturn(new Cos(Nd4j.linspace(0, Math.PI, n1))) val outerY = Nd4j.getExecutioner.execAndReturn(new Sin(Nd4j.linspace(0, Math.PI, n1))) val innerX = Nd4j.getExecutioner.execAndReturn(new Cos(Nd4j.linspace(0, Math.PI, n2))).mul(-1).add(1) val innerY = Nd4j.getExecutioner.execAndReturn(new Sin

Deeplearning4j: Iterations, Epochs, and ScoreIterationListener

◇◆丶佛笑我妖孽 提交于 2019-12-19 07:33:37
问题 Good afternoon to everybody. I'm quite new to the Deepleaning4j library and there are a couple of stuff that are still unclear to me. The concept of "epoch" is not new, thus, it is clear that it represents a full-cycle on the training set. My first doubt is related to the concept of "iteration". What is an iteration over the training set? Does it correspond to the analysis of a mini-batch number of training instances or to something else? In my code, I set ".iterations(1)"; however, when I

java深度学习库deeplearning4j使用之word2vec与INDAarry

女生的网名这么多〃 提交于 2019-12-16 09:18:04
import org.deeplearning4j.models.embeddings.loader.WordVectorSerializer; import org.deeplearning4j.models.word2vec.Word2Vec; import org.nd4j.linalg.api.ndarray.INDArray; /** *必须的maven,核心组件、nlp模块、platform *INDArray相当于python的numpy <dependency> <groupId>org.deeplearning4j</groupId> <artifactId>deeplearning4j-core</artifactId> <version>1.0.0-beta4</version> </dependency> <dependency> <groupId>org.nd4j</groupId> <artifactId>nd4j-native-platform</artifactId> <version>1.0.0-beta4</version> </dependency> <dependency> <groupId>org.deeplearning4j</groupId> <artifactId>deeplearning4j-nlp</artifactId>

Deeplearning4j: Iterations, Epochs, and ScoreIterationListener

岁酱吖の 提交于 2019-12-01 05:57:09
Good afternoon to everybody. I'm quite new to the Deepleaning4j library and there are a couple of stuff that are still unclear to me. The concept of "epoch" is not new, thus, it is clear that it represents a full-cycle on the training set. My first doubt is related to the concept of "iteration". What is an iteration over the training set? Does it correspond to the analysis of a mini-batch number of training instances or to something else? In my code, I set ".iterations(1)"; however, when I run my code I see a lot of: ... ScoreIterationListener - Score at iteration XX is yy.yyyyyy" So, if I set

如何利用deeplearning4j中datavec对图像进行处理

谁说我不能喝 提交于 2019-11-30 06:33:27
NativeImageLoader Labelloader = new NativeImageLoader(112, 112, 3,new FlipImageTransform(-1)); 一、导读 众所周知图像是有红绿蓝三种颜色堆叠而成,利用deeplearning对图像处理,必须把图像转化为张量,每一张图片由有三维张量组成,三维分别是[depth、height、width],直观来讲,就是用三个矩阵堆叠起来,每一个矩阵代表一个通道,如下图。有时候需要对图片进行旋转、缩放、裁剪、缩小填充等等复杂的操作,没有一个好用的工具,整个操作过程是非常繁琐的。今天我们就来聊一聊DL4J的datavec对图像的处理。 二、datavec-data-image代码架构 datavec-data-image是dl4j基于opencv封装的图像处理库,可以非常方便的把图片处理为张量。代码分三个重要部分,loader(图片加载器)、transform(转化器)。 1、loader:图片加载器,主要用于将图片加载并转化为张量。整个类结构如下图 2、transform转化器,主要用于对图片张量的旋转、缩放、裁剪等操作,这里列出几个比较重要的转化器。 ResizeImageTransform:缩放图片 FlipImageTransform:翻转图片,例如上线左右颠倒 CropImageTransform

Normalization是什么

笑着哭i 提交于 2019-11-30 05:29:19
一、Normalization是什么 Normalization一句话概括来说就是用一种办法,将一组数据压到均值为0,方差为1的正态分布上去,具体做法是数据集的每一个元素减去均值再除以标准差。公式如下:(请忽略参数g,g的问题很诡异,后面说) 这个公式说的更直白一点就是,把每一个a,经过平移和缩放,得到一个新值。而这样做的一个理由是,平移缩放并不会改变原始数据的分布情况,原来最大的还是最大,原来最小的还是最小。 Deeplearning中有很多Normalization的方法,有BN、LN、IN、GN等等,每一种Normalization公式都一样,只是沿着的轴不一样,BN就是沿着minibatch方向,LN就是沿着影藏层的output vector维方向,举个例子,对于四维张量[minibatch,depth、height、width],那就是沿着depth方向,把height、width维约简掉。 二、说说Layer Normalization 论文地址:http://jintianxuesha.com/?id=190 Layer Normalization对于时间序列数据有奇效,下面截一段论文的原文。这是在RNN上用Layer Normalization 简短的话说一下论文的变量含义,a表示t时刻点rnn的预输出值(还没有经过激活函数哦),h表示rnn某一个隐层t时刻点的输出