openai / baselines

OpenAI Baselines: high-quality implementations of reinforcement learning algorithms
MIT License
15.8k stars 4.88k forks source link

TypeError: _cnn_to_mlp() missing 2 required positional arguments: 'num_actions' and 'scope' #919

Open dragon28 opened 5 years ago

dragon28 commented 5 years ago

Hello OpenAI Developers,

I am trying to use the deepq.models.cnn_to_mlp() function as stated at below:

model = deepq.models.cnn_to_mlp( convs=[(int(env.observation_space.shape[1]/2), int(env.observation_space.shape[1]/2), env.observation_space.shape[0])], hiddens=[200])

act = deepq.learn(
        env,
        #q_func=model,
        network=model,
        lr=1e-3,
        #max_timesteps=50000,
        total_timesteps=50000,
        buffer_size=50000,
        exploration_fraction=0.1,
        exploration_final_eps=0.05,
        #target_network_update_freq=1,
        print_freq=10,
        #callback=liveplot.baseline_callback
    )

However, I got an error:

Colocations handled automatically by placer.
Traceback (most recent call last):
  File "agent_baseline.py", line 74, in <module>
    main()
  File "agent_baseline.py", line 66, in main
    print_freq=10,
  File "/home/dragon/quant/python/baselines/baselines/deepq/deepq.py", line 209, in learn
    param_noise=param_noise
  File "/home/dragon/quant/python/baselines/baselines/deepq/build_graph.py", line 376, in build_train
    act_f = build_act(make_obs_ph, q_func, num_actions, scope=scope, reuse=reuse)
  File "/home/dragon/quant/python/baselines/baselines/deepq/build_graph.py", line 183, in build_act
    q_values = q_func(observations_ph.get(), num_actions, scope="q_func")
  File "/home/dragon/quant/python/baselines/baselines/deepq/models.py", line 107, in q_func_builder
    latent = network(input_placeholder)
  File "/home/dragon/quant/python/baselines/baselines/deepq/models.py", line 96, in <lambda>
    return lambda *args, **kwargs: _cnn_to_mlp(convs, hiddens, dueling, layer_norm=layer_norm, *args, **kwargs)
TypeError: _cnn_to_mlp() missing 2 required positional arguments: 'num_actions' and 'scope'

I hope you guys can take a look at it and revert back.

Thanks

KevinJune commented 3 years ago

I have the same problem as you. If you solve with it please tell me. Thanks a lot.