Exception CNN neural network with java
I am trying to create a neural network in java using
deeplearning4j
, but I keep getting an error when trying to create the network.
25 Replies
⌛
This post has been reserved for your question.
Hey @Lloyd_159! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
This my the code to create the network:
It looks like the Dense layer is not accepting the output of the SubsamplingLayer, but I don't manage to fix it.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
You might need to flatten the output of the previous layer
I think you can add
.setInputTypes(InputType.convolutional(3,3,16))
in the dense layer
I think with this, you won't need nIn(16*3*3)
doesn't exist i think
so how can I do that?
I tried to look it up and read that I should use a flattenLayer by adding
.layer(new org.deeplearning4j.nn.conf.layers.FlattenLayer())
before the denseLayer, but Intellij is not accepting this, I also tried a few other way to use it but no idea how it works...what happens when doing that?
what doesn't exist?
Which DL4J version are you using?
1.0.0-M1.1 I think that's the newest one
it says
Cannot resolve symbol 'FlattenLayer'
the .setInputTypes()
Methodah it seems like that might not be per layer
Can you try
.addVertex("flatten",new PreprocessorVertex(new CnnToFeedForwardPreProcessor(3,3,16)),"input")
before the dense layer?
if that exists
I think it's available in 1.0.0-M2.1
Also I think you only need the .nIn()
in the first layer
oh actually I think setInputType
should work
and this should tell DL4J to handle that
Note: that is if you have the input as a batchSize x channels x 8 x 8 array I think
Alternatively, you could use a CnnToFeedForwardPreProcessor
I now finally managed to update to 1.0.0-M2.1 but the
.addVertex()
method still cannot be resolved.
ye doing that rn
You are using a grayscale image, right?
tho how do I know if I have the input as batchSize x channels x 8 x 8 array? ._.
How are you providing the input?
well kinda ig? but formatted like that
if that's not the case, you'd probably get an exception
?
Does your input image have exactly one channel?
yes ig
it's just a 8x8 matrix
as double[8][8]
ok that doesn't have channel information
ig just try and see what happens
you might need to change it to a
double[1][8][8]
array but idk - if it doesn't work, you'll notice it
okay, on it
oh ok that's batch size x channels x 8x8
I think it works now
it outputs something like
[main] INFO org.deeplearning4j.optimize.listeners.ScoreIterationListener - Score at iteration 96 is 4198.407877604167
but ig this is right?idk whether it's right
it could be right
but whether it learns anything useful is another thing
ye ik
thanks for your help
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@765577368030937129>.