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

Error while loading models with only dense features #508

Open
gauravbrills opened this issue Jan 26, 2023 · 1 comment
Open

Error while loading models with only dense features #508

gauravbrills opened this issue Jan 26, 2023 · 1 comment

Comments

@gauravbrills
Copy link

Describe the bug(问题描述)
Trying to run a DeepFM model withh only dense features , the models train and save fine but while loading the following exception appears

    /usr/local/lib/python3.8/dist-packages/deepctr/layers/utils.py:325 call  *
        return Add()(inputs)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:1023 __call__  **
        self._maybe_build(inputs)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:2625 _maybe_build
        self.build(input_shapes)  # pylint:disable=not-callable
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/utils/tf_utils.py:270 wrapper
        output_shape = fn(instance, input_shape)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/layers/merge.py:94 build
        batch_sizes = {s[0] for s in input_shape if s} - {None}
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/layers/merge.py:94 <setcomp>
        batch_sizes = {s[0] for s in input_shape if s} - {None}

    TypeError: unhashable type: 'list'

To Reproduce(复现步骤)
Steps to reproduce the behavior:
Use only dense features

fixlen_feature_columns= [DenseFeat(feat, 1, ) for feat in dense_features]  
dnn_feature_columns = fixlen_feature_columns
linear_feature_columns = fixlen_feature_columns
feature_names = get_feature_names(linear_feature_columns + dnn_feature_columns) 

Model

DeepFM(linear_feature_columns,dnn_feature_columns,   
                       l2_reg_linear=1e-05, 
                       l2_reg_dnn=0, 
                       dnn_dropout=0,
                       dnn_activation='relu',
                       dnn_use_bn=False,  
                       task='binary')
# save model 

Load the saved model

load_model(model_path,custom_objects) 

Gives error

[/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/impl/api.py](https://localhost:8080/#) in wrapper(*args, **kwargs)
    693       except Exception as e:  # pylint:disable=broad-except
    694         if hasattr(e, 'ag_error_metadata'):
--> 695           raise e.ag_error_metadata.to_exception(e)
    696         else:
    697           raise

TypeError: in user code:

    /usr/local/lib/python3.8/dist-packages/deepctr/layers/utils.py:325 call  *
        return Add()(inputs)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:1023 __call__  **
        self._maybe_build(inputs)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:2625 _maybe_build
        self.build(input_shapes)  # pylint:disable=not-callable
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/utils/tf_utils.py:270 wrapper
        output_shape = fn(instance, input_shape)
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/layers/merge.py:94 build
        batch_sizes = {s[0] for s in input_shape if s} - {None}
    /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/layers/merge.py:94 <setcomp>
        batch_sizes = {s[0] for s in input_shape if s} - {None}

    TypeError: unhashable type: 'list'```

**Operating environment(运行环境):**
 - python version [3.8]
 - tensorflow version 2.5.0
 - deepctr version [0.9.3]
 
@myhaa
Copy link

myhaa commented Jan 31, 2023

Hi, has it been solved? The same thing happened to me.

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

2 participants