Open minsung-k opened 5 days ago
Thank you for your question, the issue is indeed with the line you specify x = x.view(batch_size * seq_length, channels, height, width) # [batch_size * num_seq, channels, height, width]
.
Opacus expects that the input to each module has the batch size as the first or second dimension of the input (by default first). See e.g, another issue related to batch size.
There is no work-around to this. What is the source for your model architecture? Is it a standard approach to flatten the input to have dimension (batch_size * seq_length, , ) and then to re-shape it after the CNN layers to have size (batch_size, seq_length, ...)? For RNN architectures, I have not encountered this approach of essentially grouping the entire sequence into one sample.
Hi, I want to ask how to utilize CNNLSTM model in DP with Opacus.
Let's assume my data is image frames with size of [batch_size (32), num_seq (20), 1, 32, 32] and target [batch_size,]
My question is how to utilize this model in setting?
When I train the model, I keep receiving this error in this line.
optimizer.step() RuntimeError: stack expects each tensor to be equal size, but got [640] at entry 0 and [32] at entry 8
This means the first value of input size does not keep same as batch size(32).
I think the reason is this line in the model. x = x.view(batch_size seq_length, channels, height, width) # [batch_size num_seq, channels, height, width]
this line changes the input data size as [640 (32*20, channels, height, width].
How can I train DP-CNNLSTM model in this setting?
This is the model.
This is the opacus setting.