MehmetAygun / fusenet-pytorch

Other
81 stars 17 forks source link

directly call define_FuseNet #5

Closed yscoffee closed 5 years ago

yscoffee commented 5 years ago

Hi, Thanks for sharing your implementation. I am trying to directly get the network model via define_FuseNet but it seems that this line https://github.com/MehmetAygun/fusenet-pytorch/blob/master/models/networks.py#L76 need to be changed from: if children in root_child.need_initialization: to if children in net.need_initialization:

otherwise i will encounter a error.


fusenet/networks.py in define_FuseNet(num_labels, rgb_enc, depth_enc, rgb_dec, depth_dec, norm, use_dropout, init_type, init_gain, gpu_ids)
     87 
     88     net = FusenetGenerator(num_labels, rgb_enc=True, depth_enc=True, rgb_dec=True, depth_dec=False )
---> 89     return init_net(net, init_type, init_gain, gpu_ids)
     90 
     91 

/balin_ysmedia/sync/mycode/dev-project/motion_net/mnet/models/fusenet/networks.py in init_net(net, init_type, init_gain, gpu_ids)
     76         for children in root_child.children():
     77             # children in net.need_initialization:
---> 78             if children in root_child.need_initialization:
     79                 init_weights(children, init_type, gain=init_gain)
     80             else:

/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
    516                 return modules[name]
    517         raise AttributeError("'{}' object has no attribute '{}'".format(
--> 518             type(self).__name__, name))
    519 
    520     def __setattr__(self, name, value):

AttributeError: 'Sequential' object has no attribute 'need_initialization'
MehmetAygun commented 5 years ago

Are you calling the function with gpu_ids parameter ? Since we made the net parallel the net object hold parallel nets and it's childrens have need_initialization list.

yscoffee commented 5 years ago

oh.. yes, i have other code to take care that. ok thanks