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

Action names must be alphabetically ordered for ONNX inference to work. #25

Closed
Ivan-267 opened this issue Nov 28, 2023 · 0 comments · Fixed by #27
Closed

Action names must be alphabetically ordered for ONNX inference to work. #25

Ivan-267 opened this issue Nov 28, 2023 · 0 comments · Fixed by #27
Labels
bug Something isn't working

Comments

@Ivan-267
Copy link
Collaborator

This was checked with Godot_v4.2-rc2_mono_win64.

Issue:
When defining the action space, action names need to be defined in alphabetic order, e.g.

func get_action_space():
	return {
		"1" : {
		"size": 1,
			"action_type": "continuous"
		},
		"2" : {
			"size": 1,
			"action_type": "continuous"
		},        
	}

Otherwise the action space order sent to Python by the sync node will be different (it seems to be sorted alphabetically) after the dictionary goes through the JSON.stringify method: https://github.com/edbeeching/godot_rl_agents_plugin/blob/main/addons/godot_rl_agents/sync.gd#L178

So if e.g. the order defined in Godot is:

func get_action_space():
	return {
		"2" : {
		"size": 1,
			"action_type": "continuous"
		},
		"1" : {
			"size": 1,
			"action_type": "continuous"
		},        
	}

When doing Python training or inference, because of the conversion, the value for action "1" will be sent to action "2" instead.

When doing onnx inference, the actions will have the same order as defined in the action space method, which means there will be a mismatch when trying to run onnx inference in any env where the action names are not ordered alphabetically.

I ran into this issue in one of my experiments, and was able to solve it by changing the order of actions as defined to be alphabetic.
The same issue happens when trying to run inference on e.g. FlyBy where the actions are not ordered alphabetically.

@Ivan-267 Ivan-267 added the bug Something isn't working label Nov 28, 2023
@Ivan-267 Ivan-267 changed the title Bug: Action names must be alphabetically ordered for ONNX inference to work. Action names must be alphabetically ordered for ONNX inference to work. Nov 28, 2023
@Ivan-267 Ivan-267 transferred this issue from edbeeching/godot_rl_agents Nov 30, 2023
@Ivan-267 Ivan-267 linked a pull request Dec 1, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant