Skip to content

add else to avoid concatenate bug#433

Open
Xploeng wants to merge 1 commit into
Toni-SM:developfrom
Xploeng:fix/model_instatiator
Open

add else to avoid concatenate bug#433
Xploeng wants to merge 1 commit into
Toni-SM:developfrom
Xploeng:fix/model_instatiator

Conversation

@Xploeng

@Xploeng Xploeng commented Apr 28, 2026

Copy link
Copy Markdown

Reproduce and Detailed Description

Issue #432 explains the bug and has a script to reproduce it.

Bug Report

The model instantiators are bugged if you try to use "concatenate" in the output definition. Something like this:

source = gaussian_model(
        observation_space=obs_space,
        action_space=act_space,
        network=network,
        output="concatenate([head_a, head_b])",
        return_source=True,
    )

Error is:

File ".../site-packages/skrl/utils/model_instantiators/torch/common.py", line 121, in visit_Call
    activation = _get_activation_function(node.func.id, as_module=False)
                                          ^^^^^^^^^^^^
AttributeError: 'Attribute' object has no attribute 'id' 

Root cause: In _parse_output (common.py), the visit_Call method of the NodeTransformer replaces node.func with an ast.Attribute node when it encounters concatenate, but then falls through to the activation function check which assumes node.func is still an ast.Name (i.e. has .id).

Fix

Add an else after the "concatenate" block so the activation function translation is skipped if the node is a concat.

This analogous to _parse_input which has an elif ... after the if node.func.id == "concatenate": block

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

Successfully merging this pull request may close these issues.

1 participant