yunkezhang / FusionMatting

Project page for paper A Late Fusion CNN for Digital Matting.
181 stars 31 forks source link

AttributeError: 'Tensor' object has no attribute '_keras_history' #5

Open sanshibayuan opened 4 years ago

sanshibayuan commented 4 years ago

Hi, I encountered this error when I tried to train on my toy datasets, do you have any idea why? Thanks a Lot !!

It seemed to be some problem when building the Fusion model, the inference stage and the classifier training are all good.

By the way, I'm running under keras==2.1.6, tensorflow==1.10 according to the readme file.

Traceback (most recent call last): File "main.py", line 1136, in <module> model_dir=args.logs) File "main.py", line 138, in __init__ self.keras_model = self.build(mode=mode, config=config) File "main.py", line 332, in build model = KM.Model(inputs, outputs, name='fusion_network') File "/home/wm/anaconda3/envs/mpe/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/wm/anaconda3/envs/mpe/lib/python3.6/site-packages/keras/engine/topology.py", line 1734, in __init__ build_map_of_graph(x, finished_nodes, nodes_in_progress) File "/home/wm/anaconda3/envs/mpe/lib/python3.6/site-packages/keras/engine/topology.py", line 1724, in build_map_of_graph layer, node_index, tensor_index) File "/home/wm/anaconda3/envs/mpe/lib/python3.6/site-packages/keras/engine/topology.py", line 1695, in build_map_of_graph layer, node_index, tensor_index = tensor._keras_history AttributeError: 'Tensor' object has no attribute '_keras_history'

sanshibayuan commented 4 years ago

It seems to be a none-Keras operation in your matting_l1_loss implementation, whem I wraped 1. - ce_weightin a Lambda function like KL.Lambda(lambda x: 1. - x)(ce_weight), it works fine.

Original Code

matting_l1_loss = KL.Lambda(lambda x: matting_weighted_l1_loss(*x), name="matting_l1")(
                    [input_fg_alpha_gt, matting_result, 1. -  ce_weight])
yts19871111 commented 4 years ago

Hi,When I run classifier training,This kind of problem happens?

yts19871111 commented 4 years ago

Selection_010

aricsong1995 commented 3 years ago

i had encounter the same issue,when training on 'Fusion' model, have you solve the problem yet? @sanshibayuan

aricsong1995 commented 3 years ago

get code working by replaceing matting_l1_loss = KL.Lambda(lambda x: matting_weighted_l1_loss(*x), name="matting_l1")( [input_fg_alpha_gt, matting_result, KL.Lambda(lambda x: 1. - x)(ce_weight)]) with original code