@@ -451,8 +451,8 @@ def feed_forward_gaussian_fun(action_space, config, observations):
451451 if not isinstance (action_space , gym .spaces .box .Box ):
452452 raise ValueError ("Expecting continuous action space." )
453453
454- mean_weights_initializer = tf .initializers . variance_scaling (
455- scale = config .init_mean_factor )
454+ mean_weights_initializer = tf .contrib . layers . variance_scaling_initializer (
455+ factor = config .init_mean_factor )
456456 logstd_initializer = tf .random_normal_initializer (config .init_logstd , 1e-10 )
457457
458458 flat_observations = tf .reshape (observations , [
@@ -463,10 +463,10 @@ def feed_forward_gaussian_fun(action_space, config, observations):
463463 with tf .variable_scope ("policy" ):
464464 x = flat_observations
465465 for size in config .policy_layers :
466- x = tf .layers .dense (x , size , activation = tf .nn .relu )
467- mean = tf .layers .dense (
468- x , action_space .shape [0 ], activation = tf .tanh ,
469- kernel_initializer = mean_weights_initializer )
466+ x = tf .contrib . layers .fully_connected (x , size , tf .nn .relu )
467+ mean = tf .contrib . layers .fully_connected (
468+ x , action_space .shape [0 ], tf .tanh ,
469+ weights_initializer = mean_weights_initializer )
470470 logstd = tf .get_variable (
471471 "logstd" , mean .shape [2 :], tf .float32 , logstd_initializer )
472472 logstd = tf .tile (
@@ -475,8 +475,8 @@ def feed_forward_gaussian_fun(action_space, config, observations):
475475 with tf .variable_scope ("value" ):
476476 x = flat_observations
477477 for size in config .value_layers :
478- x = tf .layers .dense (x , size , activation = tf .nn .relu )
479- value = tf .layers .dense (x , 1 )[..., 0 ]
478+ x = tf .contrib . layers .fully_connected (x , size , tf .nn .relu )
479+ value = tf .contrib . layers .fully_connected (x , 1 , None )[..., 0 ]
480480 mean = tf .check_numerics (mean , "mean" )
481481 logstd = tf .check_numerics (logstd , "logstd" )
482482 value = tf .check_numerics (value , "value" )
@@ -505,14 +505,16 @@ def body(self, features):
505505 with tf .variable_scope ("policy" ):
506506 x = flat_observations
507507 for size in self .hparams .policy_layers :
508- x = tf .layers .dense (x , size , activation = tf .nn .relu )
509- logits = tf .layers .dense (x , self .hparams .problem .num_actions )
508+ x = tf .contrib .layers .fully_connected (x , size , tf .nn .relu )
509+ logits = tf .contrib .layers .fully_connected (
510+ x , self .hparams .problem .num_actions , activation_fn = None
511+ )
510512 logits = tf .expand_dims (logits , axis = 1 )
511513 with tf .variable_scope ("value" ):
512514 x = flat_observations
513515 for size in self .hparams .value_layers :
514- x = tf .layers .dense (x , size , activation = tf .nn .relu )
515- value = tf .layers .dense (x , 1 )
516+ x = tf .contrib . layers .fully_connected (x , size , tf .nn .relu )
517+ value = tf .contrib . layers .fully_connected (x , 1 , None )
516518 logits = clip_logits (logits , self .hparams )
517519 return {"target_policy" : logits , "target_value" : value }
518520
@@ -529,22 +531,23 @@ def body(self, features):
529531 dropout = getattr (self .hparams , "dropout_ppo" , 0.0 )
530532 with tf .variable_scope ("feed_forward_cnn_small" ):
531533 x = tf .cast (x , tf .float32 ) / 255.0
532- x = tf .layers .conv2d (x , 32 , ( 5 , 5 ), strides = ( 2 , 2 ) ,
533- activation = tf .nn .relu , padding = "same " )
534- x = tf .layers .conv2d (x , 32 , ( 5 , 5 ), strides = ( 2 , 2 ) ,
535- activation = tf .nn .relu , padding = "same " )
534+ x = tf .contrib . layers .conv2d (x , 32 , [ 5 , 5 ], [ 2 , 2 ] ,
535+ activation_fn = tf .nn .relu , padding = "SAME " )
536+ x = tf .contrib . layers .conv2d (x , 32 , [ 5 , 5 ], [ 2 , 2 ] ,
537+ activation_fn = tf .nn .relu , padding = "SAME " )
536538
537539 flat_x = tf .layers .flatten (x )
538540 flat_x = tf .layers .dropout (flat_x , rate = dropout )
539- x = tf .layers .dense (flat_x , 128 , activation = tf .nn .relu )
541+ x = tf .contrib . layers .fully_connected (flat_x , 128 , tf .nn .relu )
540542
541543 logits = tf .layers .dense (
542544 x , self .hparams .problem .num_actions , name = "dense2"
543545 )
544546 logits = clip_logits (logits , self .hparams )
545547 logits = tf .expand_dims (logits , axis = 1 )
546548
547- value = tf .layers .dense (x , 1 )
549+ value = tf .contrib .layers .fully_connected (
550+ x , 1 , activation_fn = None )
548551 return {"target_policy" : logits , "target_value" : value }
549552
550553
@@ -597,12 +600,15 @@ def body(self, features):
597600 with tf .variable_scope ("dense_bitwise" ):
598601 flat_x = discretization .int_to_bit_embed (flat_x , 8 , 32 )
599602
600- x = tf .layers .dense (flat_x , 256 , activation = tf .nn .relu )
601- x = tf .layers .dense (flat_x , 128 , activation = tf .nn .relu )
603+ x = tf .contrib . layers .fully_connected (flat_x , 256 , tf .nn .relu )
604+ x = tf .contrib . layers .fully_connected (flat_x , 128 , tf .nn .relu )
602605
603- logits = tf .layers .dense (x , self .hparams .problem .num_actions )
606+ logits = tf .contrib .layers .fully_connected (
607+ x , self .hparams .problem .num_actions , activation_fn = None
608+ )
604609
605- value = tf .layers .dense (x , 1 )[..., 0 ]
610+ value = tf .contrib .layers .fully_connected (
611+ x , 1 , activation_fn = None )[..., 0 ]
606612
607613 return {"target_policy" : logits , "target_value" : value }
608614
0 commit comments