Skip to content

Issue with numpy? #7

Description

@jhill1

Running an example DeepDive sim and hit this error:

/home/jh1889/dd_env/lib/python3.12/site-packages/keras/src/layers/rnn/bidirectional.py:107: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.
  super().__init__(**kwargs)
Traceback (most recent call last):
  File "/home/jh1889/run_dd_config.py", line 55, in <module>
    run()
  File "/home/jh1889/run_dd_config.py", line 45, in run
    config_runner.run_config(args.config_file, wd=args.wd, CPU=args.cpu,
  File "/home/jh1889/dd_env/lib/python3.12/site-packages/deepdive/config_runner.py", line 165, in run_config
    model_tmp = run_model_training_from_config(config, feature_file=feature_file, label_file=label_file,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jh1889/dd_env/lib/python3.12/site-packages/deepdive/deepdiver_utilities.py", line 494, in run_model_training_from_config
    model = build_rnn(Xt_r,
            ^^^^^^^^^^^^^^^
  File "/home/jh1889/dd_env/lib/python3.12/site-packages/deepdive/rnn_builder.py", line 46, in build_rnn
    model.add(layers.Dense(dense_nodes[i],
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jh1889/dd_env/lib/python3.12/site-packages/keras/src/layers/core/dense.py", line 102, in __init__
    raise ValueError(
ValueError: Received an invalid value for `units`, expected a positive integer. Received: units=64

Looks like with the latest numpy a np.int64(64) rather than a python int.

Simple fix is to change:

    for i in range(len(dense_nodes)):
        model.add(layers.Dense(dense_nodes[i],
                               activation=dense_act_f))

to

    for i in range(len(dense_nodes)):
        model.add(layers.Dense(int(dense_nodes[i]),
                               activation=dense_act_f))

in rnn_builder.py

My package list is:

Package            Version
------------------ -----------
absl-py            2.4.0
astunparse         1.6.3
certifi            2026.2.25
charset-normalizer 3.4.7
contourpy          1.3.3
cycler             0.12.1
DeepDive           1.0.28
flatbuffers        25.12.19
fonttools          4.62.1
gast               0.7.0
google-pasta       0.2.0
grpcio             1.80.0
h5py               3.14.0
idna               3.11
joblib             1.5.3
keras              3.14.0
kiwisolver         1.5.0
libclang           18.1.1
markdown-it-py     4.0.0
matplotlib         3.10.8
mdurl              0.1.2
ml_dtypes          0.5.4
namex              0.1.0
numpy              2.4.4
opt_einsum         3.4.0
optree             0.19.0
packaging          26.1
pandas             3.0.2
pillow             12.2.0
pip                24.0
protobuf           7.34.1
Pygments           2.20.0
pyparsing          3.3.2
python-dateutil    2.9.0.post0
requests           2.33.1
rich               15.0.0
scikit-learn       1.8.0
scipy              1.17.1
seaborn            0.13.2
setuptools         82.0.1
six                1.17.0
tensorflow         2.21.0
termcolor          3.3.0
threadpoolctl      3.6.0
typing_extensions  4.15.0
urllib3            2.6.3
wheel              0.46.3
wrapt              2.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions