-
I am going through the book, and in chapter 4.5.4 I see the code: Trainer trainer = model.newTrainer(config);
trainer.initialize(new Shape(batchSize, 2)); I cannot understand those parameters. Initially I though that the shape would be for the input (batch-size, number of parameters). However looking at the source code I see we can input several of these shapes. Can anyone direct me to an example that shows the use of several shapes and explain the when and why? TIA |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
When you call If your model input is a batch of RGB images of size 28x28, you would give it |
Beta Was this translation helpful? Give feedback.
When you call
trainer.initialize(shape)
, the shape you pass into it is the input shape that your model accepts. It then uses the input shape into the main block to compute the input shape into all children blocks and parameters to initialize all of them as well. So, the mapping from input shape to number of parameters is part of the block class; you don't have to worry about it.If your model input is a batch of RGB images of size 28x28, you would give it
trainer.initialize(new Shape(batchSize, 3, 28, 28))
. You could also give ittrainer.initialize(new Shape(1, 3, 28, 28))
because the batch size doesn't affect parameter initialization. Or, if it is a model that accepts two images, then it…