“real” is a mini-batch and the goal is to make a copy of that batch called “adv_ex” and add small amounts of noise (gen(item)) to each image in adv_ex, however, it throws an error that indicates that I’m using a view incorrectly. Any help interpreting this error? Thanks
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_24355/3111319459.py in <module>
14 for idx,item in enumerate(adv_ex):
15 #item.size() = 784
---> 16 purturbation = gen(item)
17 adv_ex[idx] = adv_ex[idx] + purturbation #item.size() = 784
18
RuntimeError: A view was created in no_grad mode and its base or another view of its base has been modified inplace with grad mode enabled. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.