google-research / tensor2robot

Distributed machine learning infrastructure for large-scale robotics research
https://ai.google/research/teams/brain/robotics/
Apache License 2.0
537 stars 116 forks source link

pose_env.pose_env_models_test failed #3

Closed Francis777 closed 4 years ago

Francis777 commented 4 years ago

Hi t2r team,

Thanks for open sourcing this project. Here is one bug I observe: 3 tests in PoseEnvModelsTest failed (test_regression_maml_policy_interface, test_train_eval_gin('run_train_reg.gin'), test_train_eval_gin('run_train_reg_maml.gin')) with the following same error:

ERROR: test_regression_maml_policy_interface (__main__.PoseEnvModelsTest)
test_regression_maml_policy_interface (__main__.PoseEnvModelsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/francis/code/Research/tensor2robot/research/pose_env/pose_env_models_test.py", line 122, in test_regression_maml_policy_interface
    predictor = checkpoint_predictor.CheckpointPredictor(t2r_model=t2r_model)
  File "/home/francis/venv/lib/python3.5/site-packages/gin/config.py", line 1078, in gin_wrapper
    utils.augment_exception_message_and_reraise(e, err_str)
  File "/home/francis/venv/lib/python3.5/site-packages/gin/utils.py", line 49, in augment_exception_message_and_reraise
    six.raise_from(proxy.with_traceback(exception.__traceback__), None)
  File "<string>", line 3, in raise_from
  File "/home/francis/venv/lib/python3.5/site-packages/gin/config.py", line 1055, in gin_wrapper
    return fn(*new_args, **new_kwargs)
  File "/home/francis/code/Research/tensor2robot/predictors/checkpoint_predictor.py", line 87, in __init__
    estimator_spec = t2r_model.model_fn(preprocessed_features, None, mode)
  File "/home/francis/code/Research/tensor2robot/models/abstract_model.py", line 682, in model_fn
    config, params)
  File "/home/francis/code/Research/tensor2robot/meta_learning/maml_model.py", line 325, in inference_network_fn
    task_learn, elems, mode, params)
  File "/home/francis/code/Research/tensor2robot/meta_learning/maml_model.py", line 220, in _map_task_learn
    dtypes = self.infer_base_model_output_dtypes(mode, params)
  File "/home/francis/code/Research/tensor2robot/meta_learning/maml_model.py", line 190, in infer_base_model_output_dtypes
    params=params)
  File "/home/francis/code/Research/tensor2robot/models/regression_model.py", line 150, in inference_network_fn
    list(outputs.keys())))
ValueError: For regression models inference_output is a required key in outputs but is not in ['state_features', 'action'].
  In call to configurable 'CheckpointPredictor' (<class 'tensor2robot.predictors.checkpoint_predictor.CheckpointPredictor'>)

class PoseEnvRegressionModel(in research/pose_env/pose_env_models.py) inherits from class RegressionModel(in models/regression_model.py). In the superclass it raises error if output of a_func doesn't contain key inference_output. But in the subclass the implementation of a_func returns the actual inference output with key action.

        -  return {'action': estimated_pose, 'state_features': feature_points}
        + return {'inference_output': estimated_pose, 'action': estimated_pose, 'state_features': feature_points}

After this change the tests passed. Note that simply changing action to inference output will still cause test failure with different errors, I currently haven't looked into the cause yet, would appreciate insight on that as well!

p.s. my tf version: 1.14.0

Francis777 commented 4 years ago

Another bug fix is to add

from tensorflow.contrib import framework as contrib_framework

in predictors/checkpoint_predictor.py. Otherwise contrib_framework is undefined in the constructor. I'd be happy to open a PR for these two fixes.

ericjang commented 4 years ago

Hi Francis, thanks for bringing this issue to my attention. A fix is incoming for the first issue you mentioned. As for the second, since TF latest has removed contrib, you now need to install it as a separate dependency (I may have neglected to put it in the pip requirements.txt)

Francis777 commented 4 years ago

Thanks for your quick response Eric, I'm looking forward to the update. Besides I also include the following dependencies in requirements.txt to make everything work:

tf-agents==0.3.0
gast==0.2.2

Feel free to close the issue!

ericjang commented 4 years ago

https://github.com/google-research/tensor2robot/commit/416f283b9461d2f9bf10f4f0c17af294f1f48da8 fixes the issue. I'll update the requirements.txt soon.