In CNN, can the FC (Fully Connected Layer) be sent to the CPU after convolution layer is done on the GPU? Can I use the following? Thank you.
cpu = torch.device("cpu")
self.fc1.to(cpu)
In CNN, can the FC (Fully Connected Layer) be sent to the CPU after convolution layer is done on the GPU? Can I use the following? Thank you.
cpu = torch.device("cpu")
self.fc1.to(cpu)
Yes, the code snippet you provided will move self.fc1
(i.e. its weight
and bias
parameters) to CPU because .to(cpu)
will be an in-place operation.