tawheeler / ForwardNets.jl

A simple Julia package for neural networks.
Other
0 stars 2 forks source link

too many parameters for Forwardnets? #2

Open aslandery opened 5 years ago

aslandery commented 5 years ago

Hi, tawheeler, Thanks for the great work. But when I use the package with antomotivedrivingmodels, it reports too many params for forwardnet, even when I try with simple inputs as your example, it reports the same error. Could you help me with it?

The traceback is as following:

(d_gail_2.7)gail-driver-master *$ python train_gail_model.py

: julia env dict: {'Auto2D': '/Users/*/*/gail-driver-master/julia/envs/Auto2D.jl'} statistics of initial_obs_mean (dimension: 51 ) 2018-10-17 14:12:36.789179 +03 | Warning: skipping Gym environment monitoring since snapshot_dir not configured. : env: Auto2D-v0 register.make(id): Auto2D-v0 envspec.make(): _entry_point: rltools.envs.julia_sim:JuliaEnvWrapper require wainings gym:registration.py: result: WARNING: Method definition describe(AbstractArray) in module StatsBase at /Users/*/.julia/v0.5/StatsBase/src/scalarstats.jl:560 overwritten in module DataFrames at /Users/*/.julia/v0.5/DataFrames/src/abstractdataframe/abstractdataframe.jl:407. calling ForwardNets gen_simparams is truly called with initialization nokey in args with trajdata_filepaths loading trajdatas: Any[1,2,3,4,5,6] elapsed time: 43.239445775 seconds loading training segments elapsed time: 43.052144272 seconds gen_simparams called SimParam called col_weight:0.0 off_weight:0.0 rev_weight0.0 jrk_weight0.0 acc_weight0.0 cen_weight0.0 ome_weight0.0 use_debug_rewardfalse use_playback_reactivefalse model_allfalse playback_reactive_threshold_brake-2.0 nsimstates1 prime_history2 nsteps100 ego_action_type: AutomotiveDrivingModels.AccelTurnrate extractor: Auto2D.MultiFeatureExtractor(true,false,true,false,true,Auto2D.LidarSensor([-2.82743,-2.51327,-2.19911,-1.88496,-1.5708,-1.25664,-0.942478,-0.628319,-0.314159,0.0,0.314159,0.628319,0.942478,1.25664,1.5708,1.88496,2.19911,2.51327,2.82743,3.14159],[2.8947e-314,2.8947e-314,2.87968e-314,2.87968e-314,2.8947e-314,2.8947e-314,2.87968e-314,2.87968e-314,2.88483e-314,2.87968e-314,2.87968e-314,2.90621e-314,2.87968e-314,2.87968e-314,2.87875e-314,2.87875e-314,2.87873e-314,2.87873e-314,2.87873e-314,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,6.91692e-323,0.0,0.0,0.0,0.0,0.0,0.0,0.0],100.0,ConvexPolygon: len 0 (max 4 pts) ),Auto2D.RoadlineLidarSensor(Float64[],,100.0,ConvexPolygon: len 0 (max 4 pts) ),Auto2D.RoadwayLidarCulling(true,Inf,-Inf,Inf,-Inf,#undef,#undef,#undef,#undef,Auto2D.LanePortion[])) context: AutomotiveDrivingModels.IntegratedContinuous(0.1,1) features: initialized safety_policy AutomotiveDrivingModels.LatLonSeparableDriver(AutomotiveDrivingModels.IntegratedContinuous(0.1,1),AutomotiveDrivingModels.ProportionalLaneTracker(NaN,0.1,3.0,2.0),AutomotiveDrivingModels.IntelligentDriverModel(NaN,0.1,1.0,4.0,0.5,29.0,1.0,3.0,2.5,9.0)) playback_reactive_modelAutomotiveDrivingModels.LatLonSeparableDriver(AutomotiveDrivingModels.IntegratedContinuous(0.1,1),AutomotiveDrivingModels.ProportionalLaneTracker(NaN,0.1,3.0,2.0),AutomotiveDrivingModels.IntelligentDriverModel(NaN,0.1,1.0,4.0,0.5,29.0,1.0,3.0,2.5,9.0)) choosing layer: basepath:iter00413/mlp_policy layers:String["hidden_0","hidden_1","hidden_2","hidden_3"] pull w:13056 pull b:256 Traceback (most recent call last): File "train_gail_model.py", line 222, in g_env = normalize(GymEnv(env_id), File "/Users/*/PycharmProjects/gail-driver-master/rllab/envs/gym_env.py", line 73, in __init__ env = gym.envs.make(env_name) File "/Users/*/anaconda3/envs/d_gail_2.7/lib/python2.7/site-packages/gym/envs/registration.py", line 173, in make return registry.make(id) File "/Users/*/anaconda3/envs/d_gail_2.7/lib/python2.7/site-packages/gym/envs/registration.py", line 125, in make env = spec.make() File "/Users/*/anaconda3/envs/d_gail_2.7/lib/python2.7/site-packages/gym/envs/registration.py", line 89, in make env = cls(**self._kwargs) File "/Users/*/PycharmProjects/gail-driver-master/rltools/envs/julia_sim.py", line 442, in __init__ JuliaEnvWrapper._param_dict) File "/Users/*/PycharmProjects/gail-driver-master/rltools/envs/julia_sim.py", line 49, in __init__ self.simparams = self.j.gen_simparams(batch_size, param_dict) RuntimeError: Julia exception: ErrorException("too many parameters for type ForwardNet") Thanks a lot for the help. Looking forward to your response.
tawheeler commented 5 years ago

Oh boy, that code hasn't been touched in about two years!

Looks like the only constructor for ForwardNet has zero parameters: ForwardNet(). Could whatever code you are using be trying to pass things in? If you can't figure out what method it is trying to call, perhaps try defining a three-param constructor:

function ForwardNet(dags_in, nodes_in, name_to_index_in)
    dags = dags_in
    nodes = nodes_in
    name_to_index = name_to_index_in
end
aslandery commented 5 years ago

Hi, tawheeler, I appreciate it a lot that you replied so soon. I hope to implement the code of driving-with-GAIL, thus ForwardNets is called as the policy network. Truly as you say, the constructor of ForwardNet has zero parameters. But when the code in 'load_policy.jl' tries to claim a object of ForwardNet with ForwardNet{Float32}(), it will report the above error, as shown in attached image. I will try your suggestions. A lot of thanks again for your answer.

screen shot 2018-10-18 at 11 16 28 am
tawheeler commented 5 years ago

ForwardNet doesn't appear to need a parameterization. Can probably drop the {Float32} unless the definition has been changed locally on your machine.

ForwardNet{Float32}() -> ForwardNet()
tawheeler commented 5 years ago

What version of Julia are you using? The version on master was written from julia 0.4, which is now really old. Things need to be updated.

aslandery commented 5 years ago

What version of Julia are you using? The version on master was written from julia 0.4, which is now really old. Things need to be updated.

Hi, tawheeler, Sorry for late reply. I have been working on the code and it is able to run now! I use Julia 0.5.2, python2.7. But when it comes to automotive driving, ForwardNets are reimplemented with some added gru layers, and forwardnet() is reimplemented as forwarnet{Float32}(). So for general use, removal of {Float32} is working, but for the reimplemented functions in driving, it is ok to keep {Float32}. It is my fault...I am so sorry that I didn't make it clear at beginning. I am a beginner in reinforcement learning, especially in Julia&python mixing coding for simulation. While the version is old and there are problems due to the version, I learnt much. Thanks again for your response and suggestion!