Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Aug 26 2020 22:03
    User @agibsonccc unbanned @farizrahman4u
  • Aug 26 2020 22:02
    User @agibsonccc unbanned @RobAltena
  • Aug 26 2020 22:02
    User @agibsonccc unbanned @gsw85
  • Aug 26 2020 22:02
    User @agibsonccc unbanned @raver120
  • Aug 26 2020 22:01
    User @agibsonccc unbanned @cagneymoreau
  • Aug 20 2020 21:19
    @chrisvnicholson banned @cagneymoreau
  • Aug 20 2020 21:15
    @chrisvnicholson banned @konduitops
  • Aug 20 2020 21:13
    User @chrisvnicholson unbanned @eraly
  • Aug 20 2020 21:12
    User @chrisvnicholson unbanned @treo
  • Aug 20 2020 21:12
    User @chrisvnicholson unbanned @AlexDBlack
  • Jul 07 2020 22:38
    @chrisvnicholson banned @raver120
  • May 31 2020 20:46
    @chrisvnicholson banned @ShamsUlAzeem
  • May 31 2020 20:46
    @chrisvnicholson banned @farizrahman4u
  • May 31 2020 20:44
    @chrisvnicholson banned @gsw85_twitter
  • May 31 2020 20:44
    @chrisvnicholson banned @gsw85
  • May 31 2020 20:43
    @chrisvnicholson banned @AlexDBlack
  • May 31 2020 20:43
    @chrisvnicholson banned @agibsonccc
  • May 31 2020 20:43
    @chrisvnicholson banned @RobAltena
  • May 31 2020 20:42
    @chrisvnicholson banned @eraly
  • May 31 2020 20:42
    @chrisvnicholson banned @treo
Hi , whats the difference between class NeuralNetConfiguration.Builder : optimizationAlgo and updater method ? They look same ?
and there is no AMSGrad on optimizationAlgo.Only its avalible in updater method
Adam Gibson
@eix128 please migrate your questions to the forums
We post there so other people can benefit from questions other people asked.
To answer your question, many confusing things are mainly due to new apis and backwards compatibility. Things used to be called optimization algorithms, now they're updaters to be more in line with the other industries. Please use the examples, I've seen you looking at old code and posting on old repos. I'm not sure where you keep looking (the book maybe?) but many things are there for backwards compatibility reasons and not much else. Whatever you're doing, stick to https://github.com/eclipse/deeplearning4j, https://github.com/eclipse/deeplearning4j-examples, https://community.konduit.ai/ - I mention this so you use the most up to date code from us, the most up to date examples, and join the community where the discussions' moved long ago
Everything else is likely out of date (blog posts, old repositories that haven't been touched in years etc)
Okay so you should flag optimizationAlgo method as deprecated and on javadoc you should point updater method call as alternative
Any idea why this hubert loss function would fail? Same network is working correctly for MSE loss function.
public class HuberLoss extends SameDiffLoss{

    public SDVariable defineLoss(SameDiff sd, SDVariable yPred, SDVariable yTrue) {
        return sd.loss.huberLoss(yTrue, yPred, null, 1.0);

NDArray::applyScalarArr BoolOps: this dtype: [5]; scalar dtype: [6]
Exception in thread "main" 14:24:54.952 [main] ERROR o.n.l.c.n.ops.NativeOpExecutioner - Failed to execute op huber_loss_grad. Attempted to execute with 3 inputs, 3 outputs, 1 targs,0 bargs and 1 iargs. Inputs: [(FLOAT,[1,3],c), (FLOAT,[],c), (FLOAT,[1,3],c)]. Outputs: [(FLOAT,[1,3],c), (FLOAT,[],c), (FLOAT,[1,3],c)]. tArgs: [1.0]. iArgs: [3]. bArgs: -. Input var names: [layerInput, sd_var, labels]. Output var names: [layerInput-grad, sd_var-grad, labels-grad] - Please see above message (printed out from c++) for a possible cause of error.
java.lang.RuntimeException: NDArray::applyScalarArr bool method: this and scalar arrays must have the same type!
    at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.exec(NativeOpExecutioner.java:1918)
    at org.nd4j.linalg.factory.Nd4j.exec(Nd4j.java:6575)
    at org.nd4j.autodiff.samediff.internal.InferenceSession.doExec(InferenceSession.java:487)
    at org.nd4j.autodiff.samediff.internal.InferenceSession.getOutputs(InferenceSession.java:214)
    at org.nd4j.autodiff.samediff.internal.InferenceSession.getOutputs(InferenceSession.java:60)
    at org.nd4j.autodiff.samediff.internal.AbstractSession.output(AbstractSession.java:386)
    at org.nd4j.autodiff.samediff.SameDiff.directExecHelper(SameDiff.java:2579)
    at org.nd4j.autodiff.samediff.SameDiff.batchOutputHelper(SameDiff.java:2547)
Adam Gibson
@somegituser123 it looks like you filed an issue. So others can benefit (especially in google search results) please migrate posts like this over to the forums or GH issues for bugs if you want discussion. Thanks!
Donatien Dinyad Yeto
Hi !

hello, i made my first tries with lstm models and got some model running under beta7 when i now try to update to snapshot i got the strange error:

java.lang.IllegalStateException: Sequence lengths do not match for RnnOutputLayer input and labels:Arrays should be rank 3 with shape [minibatch, size, sequenceLength] - mismatch on dimension 2 (sequence length) - input=[16, 800, 63] vs. label=[16, 56, 63]

at least it seems to be correct in batch size and sequence length and only differs in layer size. what do i oversee or doing wrong here.
.addLayer("lstm_hide1", new LSTM.Builder()
.build(), "bi_lstm")
.addLayer("rnn_out", new RnnOutputLayer.Builder()
.build() , "lstm_hide1")
would be appreciate if someone can give a hint.
Adam Gibson
@thomas-trendsoft could you please post over on the community forums? https://community.konduit.ai/ - we enforce that so others can benefit later in the search results. It also reduces repeated questions.
ok, thanks will open a thread.
Is there any comparable operation to 'tf.where' in samediff? It should behave like: condition(x[i]) ? y[i] : z[i].
The only thing I found was the SDBaseOps::replaceWhere. But this works as: condition(x[i]) ? y[i] : x[i]

Hello, I'm trying to translate something from matlab to java and I'm facing some difficulties.
I have created a dummy block of code to explain what I'm trying to do atm. I tried several things including putColumn and I'm always failing. Could you please help?

G = [1 2 3; 4 5 6; 7 8 9; 10 11 12];

for i=1:365

Adam Gibson
@officiallor @weinino mind posting over on the forums?
Good morning. I am curious about the input data needed to train CNN in the medical field. Need labeling like bounding box, polygon? If necessary, which of the two do you need? Do I just need an image? Do I need coordinate values ​​too? plz help me
Eduardo Gonzalez
Depends but polygons are used a lot.
But the model usually outputs per pixel.
@wmeddie Thank you~~
The Open Geospatial Consortium (OGC) invites developers to the July 2021 OGC API Virtual Code Sprint (scheduled for July 21st - 23rd starting at 07:00am EDT each day). Some of the participants will be implementing Web APIs based on the OGC API - Processes candidate standard that can offer access to Machine Learning (ML) algorithms. It would be great to have some implementations of DeepLearning4Java at the code sprint, wrapped inside Web APIs based on OGC API - Processes. Attend the pre-event webinar on July 14th at 09:00am EDT to get an overview of what to expect during the code sprint. Register for the Code Sprint and Webinar at https://portal.ogc.org/public_ogc/register/210721api_codesprint.php
Hello, I am trying to reproduce results of dl4j distributed training example on tinyImageNet dataset on my local dockerized Spark/Hadoop cluster. But I am getting this error: 21/07/15 19:14:03 INFO AeronUdpTransport: Adding UDP connection: [aeron:udp?endpoint=]
21/07/15 19:14:15 ERROR Executor: Exception in task 1.0 in stage 6.0 (TID 21)
org.nd4j.linalg.exception.ND4JIllegalStateException: Can't establish connection afet 10 seconds. Terminating...
at org.nd4j.parameterserver.distributed.v2.transport.impl.AeronUdpTransport.addConnection(AeronUdpTransport.java:322)
at org.nd4j.parameterserver.distributed.v2.transport.impl.AeronUdpTransport.launch(AeronUdpTransport.java:352)
Is it a networking problem ? udp ports 49876 and 40123 are aleady opend in my master and worker and my cluster is working fine for other spark tasks. Thank you
Hi! I have a multi-threaded environment where each thread reads a CSV file, builds an MLP. The code to build the MLP is shown here: https://gist.github.com/Haimonti/5f96a108ab4cded7fb3ec39cbeeb8853 Essentially, it uses a CSVRecordReader and DataSetIterator. It executes the first thread as expected but then starts throwing an error about IndexOutOfBounds.
Any suggestions on what may be wrong?

Hi, I am trying to classify a single image after creating a model with the "TransferLearningHelper" class. The examples on the dl4j repository just shows how to evaluate the test data set, but does not show how to classify a single image read from the file system , and how to save the vgg16 model - did I understand correctly that after calling the


the vgg16 model is automatically updated , and when I save this model that will be the trained model to use later ? Do I have to use the
to classify a single image ?

Adam Gibson
@javaberlin @MoslemTCM @Haimonti hey folks - please migrate your questions to: https://community.konduit.ai/ - more attention goes there and the question/answers get saved for later on google.
Hi guys. All the links on the website are broken, it is almost impossible to find anything, everytime you click it goes to the Oooops! 404 page. Should someone re-deploy the site deepleaerning4j.org ?
Eduardo Gonzalez
Oh true… wonder why that happened.
Adam Gibson
Answered on the forums, but JFYI: deeplearning4j.org isn't ours anymore and hasn't been for a while. All traffic should go to https://deeplearning4j.konduit.ai/ - beyond that I updated all the links. Shouldn't be an issue now.

I would like to use mobilenetv3 in java.
I tried to load keras model, but got error.
How can I convert keras to dl4j graph ?

import java.io.IOException;

import org.deeplearning4j.nn.graph.ComputationGraph;
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
import org.deeplearning4j.nn.modelimport.keras.exceptions.InvalidKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.exceptions.UnsupportedKerasConfigurationException;
import org.nd4j.common.io.ClassPathResource;

public class TrainModel {

    public static void main(String[] args) {
        try {
            new TrainModel().loadMobileNetV3("/pretrained_models/pretrained_mobilenetv3");//Error
//            new TrainModel().loadMobileNetV3("/pretrained_models/pretrained_mobilenetv2");//NoProblem
        } catch (IOException | UnsupportedKerasConfigurationException | InvalidKerasConfigurationException e) {
            // TODO Auto-generated catch block

    public TrainModel() {


    public void loadMobileNetV3(String path2resource) throws IOException, UnsupportedKerasConfigurationException, InvalidKerasConfigurationException {
        String fullModel = new ClassPathResource(path2resource).getFile().getPath();
        ComputationGraph model = KerasModelImport.importKerasModelAndWeights(fullModel);//h5

and, error is;

org.deeplearning4j.nn.modelimport.keras.exceptions.UnsupportedKerasConfigurationException: Unsupported keras layer type Rescaling. Please file an issue at https://github.com/eclipse/deeplearning4j/issues.
    at org.deeplearning4j.nn.modelimport.keras.utils.KerasLayerUtils.getKerasLayerFromConfig(KerasLayerUtils.java:337)
    at org.deeplearning4j.nn.modelimport.keras.KerasModel.prepareLayers(KerasModel.java:225)
    at org.deeplearning4j.nn.modelimport.keras.KerasModel.<init>(KerasModel.java:167)
    at org.deeplearning4j.nn.modelimport.keras.KerasModel.<init>(KerasModel.java:99)
    at org.deeplearning4j.nn.modelimport.keras.utils.KerasModelBuilder.buildModel(KerasModelBuilder.java:311)
    at org.deeplearning4j.nn.modelimport.keras.KerasModelImport.importKerasModelAndWeights(KerasModelImport.java:167)
    at ViewBinaryClassification.TrainModel.loadMobileNetV3(TrainModel.java:30)
    at ViewBinaryClassification.TrainModel.main(TrainModel.java:15)
Eduardo Gonzalez
Please file an issue for that layer type. I think we just need to implement it.
Adam Gibson
@tatsunidas can you file an issue so we can track this? https://github.com/eclipse/deeplearning4j/issues - it looks like a pretty easy fix
Anton Khodakivskiy
Guys, is there short guide on how to build debug version of libnd4j? I'm trying to investigate a bug in there..
Wang Qiang
question about dl4j-examples with CUDA.

I try to run example using gpu but always get this error:
"C:\Program Files\Java\jdk1.8.0_261\bin\java.exe" -Dvisualvm.id=14773048259800 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\lib\idea_rt.jar=57937:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\wangq\AppData\Local\Temp\idea_classpath1988388764 org.deeplearning4j.examples.quickstart.modeling.convolution.LeNetMNIST
o.d.e.q.m.c.LeNetMNIST - Load data....
o.d.e.q.m.c.LeNetMNIST - Build model....
o.n.l.f.Nd4jBackend - Loaded [JCublasBackend] backend
o.n.n.NativeOpsHolder - Number of threads used for linear algebra: 32
o.n.l.a.o.e.DefaultOpExecutioner - Backend used: [CUDA]; OS: [Windows 10]
o.n.l.a.o.e.DefaultOpExecutioner - Cores: [8]; Memory: [7.1GB];
o.n.l.a.o.e.DefaultOpExecutioner - Blas vendor: [CUBLAS]
o.n.l.j.JCublasBackend - ND4J CUDA build version: 11.2.142
o.n.l.j.JCublasBackend - CUDA device 0: [Quadro M2200]; cc: [5.2]; Total memory: [4294967296]
o.n.l.j.JCublasBackend - Backend build information:
MSVC: 192930038
STD version: 201703L
CUDA: 11.2.142
o.d.n.m.MultiLayerNetwork - Starting MultiLayerNetwork with WorkspaceModes set to [training: ENABLED; inference: ENABLED], cacheMode set to [NONE]
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:66)
Caused by: java.lang.RuntimeException: cudaGetSymbolAddress(...) failed; Error code: [13]
at org.nd4j.linalg.jcublas.ops.executioner.CudaExecutioner.createShapeInfo(CudaExecutioner.java:2173)
at org.nd4j.linalg.api.shape.Shape.createShapeInformation(Shape.java:3279)
at org.nd4j.linalg.api.ndarray.BaseShapeInfoProvider.createShapeInformation(BaseShapeInfoProvider.java:75)
at org.nd4j.jita.constant.ProtectedCudaShapeInfoProvider.createShapeInformation(ProtectedCudaShapeInfoProvider.java:96)
at org.nd4j.jita.constant.ProtectedCudaShapeInfoProvider.createShapeInformation(ProtectedCudaShapeInfoProvider.java:77)
at org.nd4j.linalg.jcublas.CachedShapeInfoProvider.createShapeInformation(CachedShapeInfoProvider.java:46)
at org.nd4j.linalg.api.ndarray.BaseNDArray.<init>(BaseNDArray.java:197)
at org.nd4j.linalg.jcublas.JCublasNDArray.<init>(JCublasNDArray.java:390)
at org.nd4j.linalg.jcublas.JCublasNDArrayFactory.create(JCublasNDArrayFactory.java:1528)
at org.nd4j.linalg.jcublas.JCublasNDArrayFactory.create(JCublasNDArrayFactory.java:1523)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:4299)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3987)
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.init(MultiLayerNetwork.java:688)
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.init(MultiLayerNetwork.java:604)
at org.deeplearning4j.examples.quickstart.modeling.convolution.LeNetMNIST.main(LeNetMNIST.java:116)
... 5 more

Process finished with exit code 1

nvcc like this:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Jan_28_19:41:49_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.2, V11.2.142
Build cuda_11.2.r11.2/compiler.29558016_0
Wang Qiang
nd4j-cuda-11.2-platform, version 1.0.0-M1.1 . GPU: Quadro M2200
tried 11.2 10.2 11.0, always same error
Wang Qiang
Before this keras could use GPU so CUDA should be okay.
Adam Gibson
@WangQiang102938 @akhodakivskiy mind migrating your questions to the forums? https://community.konduit.ai/ it helps prevent repeat questions.
@akhodakivskiy just add build type: --build-type to the libnd4j buildnativeoperations script in maven you can also do:
mvn -Dlibnd4j.build=debug
@WangQiang102938 the answer for you is a bit more complex. We would need info to reproduce your problem. Please migrate your question as I mentioned before. Thanks!
I would like to use ND4J to encode compressed tensors where each value is encoded as two bits, so 4 values can be encoded as a byte. Do you have any example of code that shows how to implement this. If not what is the best way to accomplish this ?
Adam Gibson
Hi @fellahst can you post over on the forums? The community has moved there it allows the web to index the discussions easier so people can find your answers later. Thanks!
Eduardo Gonzalez
Yeah. I’d like to know more about that. Seems interesting.