def unwind(self, v, ktarget): if is_eq(self, ktarget): ktarget.resume(v) else: self.k.unwind(v, ktarget)
def block_lookup(self, n, k, v): if is_eq(n, self.name): return k.unwind(v, self.cont) else: return self.others.block_lookup(n, k, v)
# forward pass with transposed kernel n_filters = cd.convweights.shape[0] inp_reshaped = inp.detach().numpy().transpose(1, 2, 3, 0).reshape(n_filters, -1) W_reshape = dilated.reshape(n_filters, -1) out_col = W_reshape.T @ inp_reshaped # image is recovered through col2im out_image = col2im_indices(out_col, cd.inp.shape, dilated_size, dilated_size, padding=padding) is_eq(output, out_image) ################################################################################################ ### Backward Pass dout_col = im2col_indices(cd.convlossTrans.detach().numpy(), dilated_size, dilated_size, padding=padding) #dout_reshaped = cd.convlossTrans.detach().numpy().transpose(1, 2, 3, 0).reshape(n_filter, -1) dX_col = W_reshape @ dout_col c, _, h, w = inp.shape dX = dX_col.reshape(n_filters, h, w, c).transpose(3, 0, 1, 2) is_eq(dX, inp.grad) dW = dout_col @ inp_reshaped.T dW = dW.reshape(dilated.shape)