mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 17:45:08 +08:00
[rllib] Better error message for unsupported non-atari image observation sizes (#3444)
This commit is contained in:
@@ -16,7 +16,7 @@ class VisionNetwork(Model):
|
||||
inputs = input_dict["obs"]
|
||||
filters = options.get("conv_filters")
|
||||
if not filters:
|
||||
filters = get_filter_config(options)
|
||||
filters = get_filter_config(inputs)
|
||||
|
||||
activation = get_activation_fn(options.get("conv_activation"))
|
||||
|
||||
@@ -47,7 +47,7 @@ class VisionNetwork(Model):
|
||||
return flatten(fc2), flatten(fc1)
|
||||
|
||||
|
||||
def get_filter_config(options):
|
||||
def get_filter_config(inputs):
|
||||
filters_84x84 = [
|
||||
[16, [8, 8], 4],
|
||||
[32, [4, 4], 2],
|
||||
@@ -58,12 +58,15 @@ def get_filter_config(options):
|
||||
[32, [4, 4], 2],
|
||||
[256, [11, 11], 1],
|
||||
]
|
||||
dim = options.get("dim")
|
||||
if dim == 84:
|
||||
shape = inputs.shape.as_list()[1:]
|
||||
if len(shape) == 3 and shape[:2] == [84, 84]:
|
||||
return filters_84x84
|
||||
elif dim == 42:
|
||||
elif len(shape) == 3 and shape[:2] == [42, 42]:
|
||||
return filters_42x42
|
||||
else:
|
||||
raise ValueError(
|
||||
"No default configuration for image size={}".format(dim) +
|
||||
", you must specify `conv_filters` manually as a model option.")
|
||||
"No default configuration for obs input {}".format(inputs) +
|
||||
", you must specify `conv_filters` manually as a model option. "
|
||||
"Default configurations are only available for inputs of size "
|
||||
"[?, 42, 42, K] and [?, 84, 84, K]. You may alternatively want "
|
||||
"to use a custom model or preprocessor.")
|
||||
|
||||
Reference in New Issue
Block a user