deeplearning4j / deeplearning4j

Suite of tools for deploying and training deep learning models using the JVM. Highlights include model import for keras, tensorflow, and onnx/pytorch, a modular and tiny c++ library for running math code and a java based math library on top of the core c++ library. Also includes samediff: a pytorch/tensorflow like library for running deep learn...
http://deeplearning4j.konduit.ai
Apache License 2.0
13.71k stars 3.84k forks source link

backprop(Layer, WorkspaceMgr) clears Dropout mask #7641

Closed dembanakh closed 5 years ago

dembanakh commented 5 years ago

dl4j 1.0.0-beta3 as well as zoo

In previous issue, i point out a problem in StyleTransfer with Squeezenet. Here i do the same thing (code from https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/styletransfer/NeuralStyleTransfer.java), but now with DarkNet19 pretrained instead of VGG16. The problem is I cannot execute StyleTransfer with more than 1 layer in STYLE_LAYERS array - after my looking into it, it seems that dropout masks are cleared after these line dLdAnext = layer.backpropGradient(dLdAnext, LayerWorkspaceMgr.noWorkspaces()).getSecond(); in backPropagate function

I get an error: Cannot perform backprop: Dropout mask array is absent (already cleared?) after the STYLE_LAYERS[1] gets backpropagated down beginning from its index. When it reaches STYLE_LAYERS[0] in graph, it says that there is no mask;

So, is it a bug or I do not pointed to the net the fact that i do not want to clear mask?

dembanakh commented 5 years ago

UPD: After I added Graph.feedForward() before every STYLE_LAYER it works. Thus, it means, that dropout masks are really got cleared after one backpropagation. Is there an option to forbid that or is it a bug?

dembanakh commented 5 years ago

I resolved the problem by storing Dropout masks for each layer in a Map.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.