# Basic deeplearning4j classification example

**URL:** <https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110>\
**Category:** DL4J\
**Created:** [January 29, 2020, 1:27pm UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110 "2020-01-29T13:27:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sogawa-sps](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sogawa-sps/32/44_2.png) [@sogawa-sps](https://community.konduit.ai/u/sogawa-sps)\
**Post date:** [January 29, 2020, 1:27pm UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110/1 "2020-01-29T13:27:21Z")

</div>

Hi All!

Need a very simple example for a jump-start [java - Basic deeplearning4j classification example - Stack Overflow](https://stackoverflow.com/questions/59923354/basic-deeplearning4j-classification-example) If somebody can share it it’d really save me some time 🙂

---

<div class="post-metadata">

**Author:** ![eduardo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/eduardo/32/24_2.png) [@eduardo](https://community.konduit.ai/u/eduardo)\
**Post date:** [January 29, 2020, 1:46pm UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110/2 "2020-01-29T13:46:56Z")

</div>

What’s wrong with the example that Susan posted? Did you have any more specific problem with it? If you have arrays of floats, just turn them into an `INDArray` using `putScalar()` like in the example or by using `Nd4j.create(double[][])`.

To transform the output of a neural network into a double array just use `.toDoubleMatrix` or `.toDoubleVector` from the result.

---

<div class="post-metadata">

**Author:** ![sogawa-sps](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sogawa-sps/32/44_2.png) [@sogawa-sps](https://community.konduit.ai/u/sogawa-sps)\
**Post date:** [January 29, 2020, 2:02pm UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110/3 "2020-01-29T14:02:59Z")

</div>

Hi! It’s totally fine, thank you very much! I’ve already started working on my project basing on her example.

I had post this message here before Susan replied on Stackoverflow but my post appeared only now by some reason.

---

<div class="post-metadata">

**Author:** ![sogawa-sps](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sogawa-sps/32/44_2.png) [@sogawa-sps](https://community.konduit.ai/u/sogawa-sps)\
**Post date:** [February 3, 2020, 12:45am UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110/4 "2020-02-03T00:45:21Z")

</div>

@eduardo I continued to work on my model the is based on Susan’s example and tried to utilize GPU for training but I can’t say that it became astonishingly quicker. GPU load was 2-3% sometimes 5%, memory utilization 1.8/6 Gb on network like this and ~10k training set:

```
=======================================================================
LayerName (LayerType) nIn,nOut TotalParams ParamsShape           
=======================================================================
layer0 (DenseLayer) 52,208 11,024 W:{52,208}, b:{1,208} 
layer1 (DenseLayer) 208,104 21,736 W:{208,104}, b:{1,104}
layer2 (OutputLayer) 104,42 4,410 W:{104,42}, b:{1,42}  
-----------------------------------------------------------------------
            Total Parameters: 37,170
        Trainable Parameters: 37,170
           Frozen Parameters: 0
=======================================================================

```

If you can give me some quick hint where to start looking for mistakes it would be great :).

---

<div class="post-metadata">

**Author:** ![eduardo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/eduardo/32/24_2.png) [@eduardo](https://community.konduit.ai/u/eduardo)\
**Post date:** [February 3, 2020, 4:10am UTC](https://community.konduit.ai/t/basic-deeplearning4j-classification-example/110/5 "2020-02-03T04:10:20Z")

</div>

It is quite normal for small networks like that to be slower on the GPU since it’s spending most of it’s time coordinating thousands of cores rather than doing the computation. If you use a neural network like YOLO that has over 60,000,000 parameters (and much more computationally intensive convolution operations) on a much larger data set, you’ll see the GPU outperform the CPU.

To see the difference with your data. try a large minibatch size of 1024 or 4096 (as much as fits in your GPU memory) and use try double or triple the dense layers. I can’t guarantee that such an over-parameterized network will be any good, but it should show the performance difference.
