Hello,
I’m new to pytorch, and I’m trying to write my own custom loss function. I am creating a model that performs image translation (mapping an image from a domain A to a domain B), and one of the components of the loss function is that I want to enforce the low-frequency of the image to remain the same (  blur(input) =blur(output) ).
From the existing posts, I tried to write a nn.Module to perform a simple GaussianBlur (dunno if there exists a simple function that do that), and I am planning to it before computing the MSE (e.g., MSE( GaussianBlur(input) , GaussianBlur(output))  ).
But I fear that during training this GaussianBlur might learn and update its intrinsic parameters, so I need to freeze those parameters from updating. From what I’ve read, I believe I should use requires_grad=False, but I really do not know where should I put it. I am sending an ipynb of my module:

  
      github.com
  
  
    bernardohenz/pytorch_learning/blob/master/blur_nnModule.ipynb 8
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from display_images import show_images\n",
    "import numpy as np\n",
    "import torch\n",
    "import torch.nn as nn\n",


  This file has been truncated. show original