存储embedding矩阵参数出错
Created by: luolimingfighting
我的组网是这样的: sparse_input_feature_idx = fluid.layers.data(name="feature_idx", shape=[1], lod_level=1, dtype="int64") sparse_input_feature_value_float = fluid.layers.data(name="feature_value", shape=[1], lod_level=1, dtype="float32") sparse_input_emb_weight = fluid.layers.embedding( input=sparse_input_feature_idx, is_sparse=True, # you need to patch https://github.com/PaddlePaddle/Paddle/pull/14190 # if you want to set is_distributed to True is_distributed=False, size=[sparse_feature_dim, emb_size],)
#x = fluid.layers.data(name="x", shape=[max_value+1], dtype="float32") y = fluid.layers.data(name="y", shape=[1], dtype="int64") w_mat_x_with_lod = sparse_input_feature_value_float * sparse_input_emb_weight w_mat_x = fluid.layers.sequence_pool(input=w_mat_x_with_lod, pool_type='sum')
def network(input): #fc = fluid.layers.fc(input=input, size=label_index+1, act="softmax") fc = fluid.layers.softmax(input=input, axis=-1) return fc model = network(w_mat_x) cost = fluid.layers.cross_entropy(input=model, label=y) 我现在想存储上述embedding矩阵的参数,用fluid.save(main_program, save_path)保存报错: W0824 17:15:12.119884 3714 device_context.cc:252] Please NOTE: device: 0, CUDA Capability: 70, Driver API Version: 10.2, Runtime API Version: 10.0 W0824 17:15:12.125532 3714 device_context.cc:260] device: 0, cuDNN Version: 7.6. Traceback (most recent call last): File "train.py", line 149, in fluid.save(main_program, save_path) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/site-packages/paddle/fluid/io.py", line 1606, in save pickle.dump(param_dict, f, protocol=2) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 1376, in dump Pickler(file, protocol).dump(obj) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 224, in dump self.save(obj) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 655, in save_dict self._batch_setitems(obj.iteritems()) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 692, in _batch_setitems save(v) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 425, in save_reduce save(state) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 568, in save_tuple save(element) File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/opt/_internal/cpython-2.7.15-ucs4/lib/python2.7/pickle.py", line 492, in save_string self.write(BINSTRING + pack("<i", n) + obj) struct.error: 'i' format requires -2147483648 <= number <= 2147483647 照理说embedding矩阵的参数不应该超过这个范围吧,麻烦帮忙看看是哪里出问题了。