Skip to content

[BUG] InvalidArgumentError when using zero sel #899

@njzjz

Description

@njzjz

Summary

When using zero sel, I got an InvalidArgumentError.

Deepmd-kit version, installation way, input file, running commands, error log, etc.

version: dea7623

        "descriptor": {
            "type": "hybrid",
            "list": [
                {
                    "type": "se_a",
                    "sel": [
                        6,
                        11,
                        0,
                        6,
                        0,
                        1
                    ],
                    "rcut_smth": 40.0,
                    "rcut": 41.0,
                    "neuron": [
                        25,
                        50,
                        100
                    ],
                    "resnet_dt": false,
                    "axis_neuron": 12, 
                    "exclude_types": [
                        [
                            2,
                            2
                        ],
                        [
                            2,
                            4
                        ],
                        [
                            4,
                            4
                        ],
                        [
                            0,
                            2
                        ],
                        [
                            0,
                            4
                        ],
                        [
                            1,
                            2
                        ],
                        [
                            1,
                            4
                        ],
                        [
                            3,
                            2
                        ],
                        [
                            3,
                            4
                        ],
                        [
                            5,
                            2
                        ],
                        [
                            5,
                           4
                        ]
                    ],
                    "set_davg_zero": true,
                    "seed": 734338485
                },
                {
                    "type": "se_a",
                    "sel": [
                        6,
                        11,
                        300,
                        6,
                        150,
                        1
                    ],
                    "rcut_smth": 1.0,
                    "rcut": 9.0,
                    "neuron": [
                        25,
                        50,
                        100
                    ],
                    "resnet_dt": false,
                    "axis_neuron": 12,
                    "exclude_types": [
                        [
                            2,
                            2
                        ],
                        [
                            2,
                            4
                        ],
                        [
                            4,
                            4
                        ],
                        [
                            0,
                            0
                        ],
                        [
                            0,
                            1
                        ],
                        [
                            0,
                            3
                        ],
                        [
                            0,
                            5
                        ],
                        [
                            1,
                            1
                        ],
                        [
                            1,
                            3
                        ],
                        [
                            1,
                            5
                        ],
                        [
                            3,
                            3
                        ],
                        [                                                                                                                                                                                                                                                                                                     
                            3,
                            5
                        ],
                        [
                            5,
                            5
                        ]
                    ],
                    "set_davg_zero": true,
                    "seed": 2082083376
                }
            ]
    }
Traceback (most recent call last):
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1375, in _do_call
    return fn(*args)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1359, in _run_fn
    return self._call_tf_sessionrun(options, feed_dict, fetch_list,
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1451, in _call_tf_sessionrun
    return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: Incompatible shapes: [146,4,100] vs. [584,4,100]
	 [[{{node filter_type_2_0/add_1}}]]
	 [[l2_virial_test/_45]]
  (1) Invalid argument: Incompatible shapes: [146,4,100] vs. [584,4,100]
	 [[{{node filter_type_2_0/add_1}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jz748/ambertools-dp/bin/dp", line 10, in <module>
    sys.exit(main())
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/entrypoints/main.py", line 419, in main
    train(**dict_args)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/entrypoints/train.py", line 212, in train
    _do_work(jdata, run_opt)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/entrypoints/train.py", line 266, in _do_work
    model.train(train_data, valid_data)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/train/trainer.py", line 512, in train
    self.valid_on_the_fly(fp, [train_batch], valid_batches, print_header=True)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/train/trainer.py", line 588, in valid_on_the_fly
    train_results = self.get_evaluation_results(train_batches)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/train/trainer.py", line 640, in get_evaluation_results
    results = self.loss.eval(self.sess, feed_dict, natoms)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/loss/ener.py", line 140, in eval
    error, error_e, error_f, error_v, error_ae, error_pf = run_sess(sess, run_data, feed_dict=feed_dict)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/deepmd/utils/sess.py", line 20, in run_sess
    return sess.run(*args, **kwargs)
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 967, in run
    result = self._run(None, fetches, feed_dict, options_ptr,
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1190, in _run
    results = self._do_run(handle, final_targets, final_fetches,
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1368, in _do_run
    return self._do_call(_run_fn, feeds, fetches, targets, options,
  File "/home/jz748/ambertools-dp/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1394, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: Incompatible shapes: [146,4,100] vs. [584,4,100]
	 [[node filter_type_2_0/add_1 (defined at /lib/python3.8/site-packages/deepmd/descriptor/se_a.py:669) ]]
	 [[l2_virial_test/_45]]
  (1) Invalid argument: Incompatible shapes: [146,4,100] vs. [584,4,100]
	 [[node filter_type_2_0/add_1 (defined at /lib/python3.8/site-packages/deepmd/descriptor/se_a.py:669) ]]
0 successful operations.
0 derived errors ignored.

Errors may have originated from an input operation.
Input Source operations connected to node filter_type_2_0/add_1:
 filter_type_2_0/MatMul_5 (defined at /lib/python3.8/site-packages/deepmd/descriptor/se_a.py:627)

Input Source operations connected to node filter_type_2_0/add_1:
 filter_type_2_0/MatMul_5 (defined at /lib/python3.8/site-packages/deepmd/descriptor/se_a.py:627)

Original stack trace for 'filter_type_2_0/add_1':
  File "/bin/dp", line 10, in <module>
    sys.exit(main())
  File "/lib/python3.8/site-packages/deepmd/entrypoints/main.py", line 419, in main
    train(**dict_args)
  File "/lib/python3.8/site-packages/deepmd/entrypoints/train.py", line 212, in train
    _do_work(jdata, run_opt)
  File "/lib/python3.8/site-packages/deepmd/entrypoints/train.py", line 262, in _do_work
    model.build(train_data, stop_batch)
  File "/lib/python3.8/site-packages/deepmd/train/trainer.py", line 316, in build
    self._build_network(data)
  File "/lib/python3.8/site-packages/deepmd/train/trainer.py", line 343, in _build_network
    = self.model.build (self.place_holders['coord'],
  File "/lib/python3.8/site-packages/deepmd/model/ener.py", line 154, in build
    = self.descrpt.build(coord_,
  File "/lib/python3.8/site-packages/deepmd/descriptor/hybrid.py", line 173, in build
    dout = ii.build(coord_, atype_, natoms, box_, mesh, input_dict, suffix=suffix+f'_{idx}', reuse=reuse)
  File "/lib/python3.8/site-packages/deepmd/descriptor/se_a.py", line 377, in build
    self.dout, self.qmat = self._pass_filter(self.descrpt_reshape,
  File "/lib/python3.8/site-packages/deepmd/descriptor/se_a.py", line 468, in _pass_filter
    layer, qmat = self._filter(tf.cast(inputs_i, self.filter_precision), type_i, name='filter_type_'+str(type_i)+suffix, natoms=natoms, reuse=reuse, trainable = trainable, activation_fn = self.filter_activation_fn)
  File "/lib/python3.8/site-packages/deepmd/descriptor/se_a.py", line 669, in _filter
    xyz_scatter_1+= ret
  File "/lib/python3.8/site-packages/tensorflow/python/ops/math_ops.py", line 1164, in binary_op_wrapper
    return func(x, y, name=name)
  File "/lib/python3.8/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/lib/python3.8/site-packages/tensorflow/python/ops/math_ops.py", line 1486, in _add_dispatch
    return gen_math_ops.add_v2(x, y, name=name)
  File "/lib/python3.8/site-packages/tensorflow/python/ops/gen_math_ops.py", line 481, in add_v2
    _, _, _op, _outputs = _op_def_library._apply_op_helper(
  File "/lib/python3.8/site-packages/tensorflow/python/framework/op_def_library.py", line 748, in _apply_op_helper
    op = g._create_op_internal(op_type_name, inputs, dtypes=None,
  File "/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 3528, in _create_op_internal
    ret = Operation(
  File "/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 1990, in __init__
    self._traceback = tf_stack.extract_stack()

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions