Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sanshibayuan opened this issue Apr 27, 2020 · 5 comments
Open

Comments

@sanshibayuan
Copy link

sanshibayuan commented Apr 27, 2020

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
Copy link
Author

It seems to be a none-Keras operation in your matting_l1_loss implementation, whem I wraped 1. - ce_weight in 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
Copy link

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

@yts19871111
Copy link

Selection_010

@aricsong1995
Copy link

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

@aricsong1995
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants