From 2517a7344cb2103c43511775a05eca0a37260429 Mon Sep 17 00:00:00 2001 From: eason du <8177dph@gmail.com> Date: Tue, 13 Dec 2022 20:01:16 +0100 Subject: [PATCH] scala examples for pytorch --- pytorch/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pytorch/README.md b/pytorch/README.md index 7f0f97d5c39..ac3aeafc111 100644 --- a/pytorch/README.md +++ b/pytorch/README.md @@ -157,3 +157,24 @@ public class SimpleMNIST { } } ``` + +### Scala examples +```scala +//2 layer lstm +import org.bytedeco.pytorch._ +val rnn: LSTMImpl = register_module( + "lstm" + mName, + new LSTMImpl(new LSTMOptions(hidden_size, hidden_size) { num_layers().put(n_layers) }) +) + +// create tensor +val decoder_input_init: Tensor = + AbstractTensor.create( + Array(outLen), + 1 + ) +``` + +### additional info + +check here for various discussion : https://github.com/bytedeco/javacpp-presets/issues/623