MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / modify_commandline_options

Method modify_commandline_options

models/simdcl_model.py:17–49  ·  view source on GitHub ↗

Configures options specific for SIMDCL.

(parser, is_train=True)

Source from the content-addressed store, hash-verified

15
16 @staticmethod
17 def modify_commandline_options(parser, is_train=True):
18 """ Configures options specific for SIMDCL.
19 """
20 parser.add_argument('--DCL_mode', type=str, default="SIM", choices='SIM')
21 parser.add_argument('--lambda_GAN', type=float, default=1.0, help='weight for GAN loss:GAN(G(X))')
22 parser.add_argument('--lambda_NCE', type=float, default=2.0, help='weight for NCE loss: NCE(G(X), X)')
23 parser.add_argument('--lambda_SIM', type=float, default=10.0, help='weight for NCE loss: NCE(G(X), X)')
24 parser.add_argument('--nce_idt', type=util.str2bool, nargs='?', const=True, default=False,
25 help='use NCE loss for identity mapping: NCE(G(Y), Y))')
26 parser.add_argument('--nce_layers', type=str, default='4,8,12,16', help='compute NCE loss on which layers')
27 parser.add_argument('--nce_includes_all_negatives_from_minibatch',
28 type=util.str2bool, nargs='?', const=True, default=False,
29 help='(used for single image translation) If True, include the negatives from the other samples of the minibatch when computing the contrastive loss. Please see models/patchnce.py for more details.')
30 parser.add_argument('--netF', type=str, default='mlp_sample', choices=['sample', 'reshape', 'mlp_sample'],
31 help='how to downsample the feature map')
32 parser.add_argument('--netF_nc', type=int, default=256)
33 parser.add_argument('--nce_T', type=float, default=0.07, help='temperature for NCE loss')
34 parser.add_argument('--num_patches', type=int, default=256, help='number of patches per layer')
35 parser.add_argument('--flip_equivariance',
36 type=util.str2bool, nargs='?', const=True, default=False,
37 help="useless")
38
39 parser.set_defaults(pool_size=0) # no image pooling
40
41 opt, _ = parser.parse_known_args()
42
43 # Set default parameters for SIMDCL.
44 if opt.DCL_mode.lower() == "sim":
45 parser.set_defaults(nce_idt=True, lambda_NCE=2.0)
46 else:
47 raise ValueError(opt.DCL_mode)
48
49 return parser
50
51 def __init__(self, opt):
52 BaseModel.__init__(self, opt)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected