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

GatherND INVALID_ARGUMENT Requested more than 0 entries #5

Open
pxc2575 opened this issue Jul 21, 2024 · 4 comments
Open

GatherND INVALID_ARGUMENT Requested more than 0 entries #5

pxc2575 opened this issue Jul 21, 2024 · 4 comments
Assignees

Comments

@pxc2575
Copy link

pxc2575 commented Jul 21, 2024

2024-07-21 15:59:45.886551: W tensorflow/core/framework/op_kernel.cc:1828] OP_REQUIRES failed at gather_nd_op.cc:48 : INVALID_ARGUMENT: Requested more than 0 entries, but params is empty.  Params shape: [64,2,1,0]
Traceback (most recent call last):
  File "D:\knowledge_graph\pix2rule-master\train.py", line 332, in <module>
    mlflow_train()
  File "D:\knowledge_graph\pix2rule-master\train.py", line 314, in mlflow_train
    tfunc(run_name=run_id, initial_epoch=initial_epoch)
  File "D:\knowledge_graph\pix2rule-master\train.py", line 240, in train
    model.fit(
  File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\tensorflow\python\eager\execute.py", line 53, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: Graph execution error:

Detected at node 'relsgame_model/dnf_layer/BatchGatherND/GatherNd' defined at (most recent call last):
    File "D:\knowledge_graph\pix2rule-master\train.py", line 332, in <module>
      mlflow_train()
    File "D:\knowledge_graph\pix2rule-master\train.py", line 314, in mlflow_train
      tfunc(run_name=run_id, initial_epoch=initial_epoch)
    File "D:\knowledge_graph\pix2rule-master\train.py", line 240, in train
      model.fit(
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 65, in error_handler
      return fn(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 1742, in fit
      tmp_logs = self.train_function(iterator)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 1338, in train_function
      return step_function(self, iterator)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 1322, in step_function
      outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 1303, in run_step
      outputs = model.train_step(data)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 1080, in train_step
      y_pred = self(x, training=True)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 65, in error_handler
      return fn(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\training.py", line 569, in __call__
      return super().__call__(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 65, in error_handler
      return fn(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\base_layer.py", line 1150, in __call__
      outputs = call_fn(inputs, *args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 96, in error_handler
      return fn(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\functional.py", line 512, in call
      return self._run_internal_graph(inputs, training=training, mask=mask)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\functional.py", line 669, in _run_internal_graph
      outputs = node.layer(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 65, in error_handler
      return fn(*args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\engine\base_layer.py", line 1150, in __call__
      outputs = call_fn(inputs, *args, **kwargs)
    File "D:\pytorch\anaconda3\envs\pytorch\lib\site-packages\keras\src\utils\traceback_utils.py", line 96, in error_handler
      return fn(*args, **kwargs)
    File "D:\knowledge_graph\pix2rule-master\components\dnf_layer.py", line 216, in call
      in_tensor = self.compute_permutations(inputs)
    File "D:\knowledge_graph\pix2rule-master\components\dnf_layer.py", line 171, in compute_permutations
      perm_binary = tf.gather_nd(
Node: 'relsgame_model/dnf_layer/BatchGatherND/GatherNd'
Requested more than 0 entries, but params is empty.  Params shape: [64,2,1,0]
	 [[{{node relsgame_model/dnf_layer/BatchGatherND/GatherNd}}]] [Op:__inference_train_function_8433]
@nuric nuric self-assigned this Jul 21, 2024
@nuric nuric changed the title "Did I miss any files? Why is it throwing an error?" GatherND INVALID_ARGUMENT Requested more than 0 entries Jul 21, 2024
@nuric
Copy link
Owner

nuric commented Jul 21, 2024

Looking at the error, I would guess that you don't have any binary predicates. Params shape: [64,2,1,0] means the tensor is empty. You have a batch size of 64, 2 constants / objects, 1 other object but 0 binary predicates. The original experiments always had binary predicates.

To fix this, it might be easier to just add 1 binary predicate to learn if you can. Otherwise, you may also be able to comment out:

  # This is where the error is
   perm_binary = tf.gather_nd(
        inputs["binary"], repeat_bidxs, batch_dims=1
    )  # (B, K, V, V-1, P2)
    # ---------------------------
    # Compute flattened input
    in_tensor = flatten_concat(
        # You may then remove perm_binary
        [perm_nullary, perm_unary, perm_binary], batch_dims=2
    )

I say may, because I don't remember whether the downstream elements and parameters make computations for binary predicates.

@nuric
Copy link
Owner

nuric commented Jul 21, 2024

The expected input to these layers are:

{'nullary_preds': (B, P0), 'unary_preds': (B, N, P1), 'binary_preds': (B, N, N-1, P2)}

and probably assume they are non-empty tensors.

@pxc2575
Copy link
Author

pxc2575 commented Jul 21, 2024

I printed the input tensor, and all my parameter settings are the default settings from the original experiment. However, the program doesn't run when I comment out that code snippet. How can I add a binary predicate for learning?
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, 1, 8)
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, None, 0)
art_dir data\active_runs\20240721-202400\8f1d95344847441da026dcb638658a82
INFO:main:Model has 2776 many parameters.
INFO:main:Local artifact dir is data\active_runs\20240721-202400\8f1d95344847441da026dcb638658a82
INFO:main:Saving task description to data\active_runs\20240721-202400\8f1d95344847441da026dcb638658a82\task_description.json
INFO:main:Starting training.
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, 1, 8)
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, None, 0)
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, 1, 8)
repeat_bidxs (None, 2, 2, 1, 2)
inputs[binary] (None, 2, None, 0)
2024-07-21 20:24:13.352765: W tensorflow/core/framework/op_kernel.cc:1828] OP_REQUIRES failed at gather_nd_op.cc:48 : INVALID_ARGUMENT: Requested more than 0 entries, but params is empty. Params shape: [64,2,1,0]

@nuric
Copy link
Owner

nuric commented Jul 21, 2024

THe number of nullary, unary and binary relations are specificied with the arities configuration. When the experiments.py is run it generates configurations which uses different number of predicates. It is specificied as an array [0,0,1,1,1,2,2] which means 2 nullary, 3 unary and 2 binary predicates.

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