Search code examples
javadeeplearning4jdl4jcomputation-graph

Putting a ComputationGraph in the resources directory in a JAR DL4j


Under normal circumstances, I can save a ComputationGraph (a Convolutional Neural Network) to a file and load it in a later run and it works fine.

However, when I include it in a jar and I try to load it, it fails.

Is there some way to load ComputationGraph objects from inside of a Jar as a resource?

I got it working for the Word2Vec objects, but it fails on ComputationGraph objects.

Thank you


Solution

  • It's just a zip file (or should be!). I'm not sure if you're using our ModelSerializer (this is the only thing you should be using for computation graph or multi layer network) - you can use an InputStream or a File when you call:

    ModelServer.restoreComputationGraph

    on an InputStream. That InputStream could be a classpath resource input stream (using something like spring's ClassPathResource) or calling a YourClass.class.getResourceAsStream(..) - any of those should work fine for you.