Skip to content

Bug and/or dead code in modular_network.py? #83

@shankstm

Description

@shankstm

In particular, see here:

# Dict[Dim, SubModule]
# instantiate heads based on output_shapes
head_submodules = {}
for output_key, shape in output_space.items():
dim = len(shape)
if dim in head_submodules:
continue
elif dim == 1:
submod_cls = net_reg.lookup_submodule(args.head1d)
elif dim == 2:
submod_cls = net_reg.lookup_submodule(args.head2d)
elif dim == 3:
submod_cls = net_reg.lookup_submodule(args.head3d)
elif dim == 4:
submod_cls = net_reg.lookup_submodule(args.head4d)
else:
raise ValueError("Invalid dim: {}".format(dim))
submod = submod_cls.from_args(
args,
body_submod.output_shape(submod_cls.dim),
"head" + str(dim) + "d",
)
head_submodules[str(dim)] = submod

In the following if-statement:

if dim in head_submodules:
    continue

type(dim) == int; however, keys of head_submodules are guaranteed to be str due to the line head_submodules[str(dim)] = submod. This suggests that the above if-statement will never continue. Thoughts on this?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions