def set_bn_eval(m):
    classname = m.__class__.__name__
    if classname.find('BatchNorm') != -1:
      m.eval()

model.apply(set_bn_eval)

you should use apply instead of searching its children.
named_children() doesn’t iteratively search submodules.