Reputation: 431
How I could migrate this layer to tf2
observations = tf.placeholder(tf.float32,[None, OBSERVATIONS_SIZE])
h = tf.layers.dense(
observations,
units=hidden_layer_size,
activation=tf.nn.relu,
kernel_initializer=tf.contrib.layers.xavier_initializer()
)
I Found that the placeholder now is 'Input' and I used the Dense layers for tf2
I tried with:
observations = tf.keras.Input(
shape = [ None, OBSERVATIONS_SIZE ],
dtype = tf.float32
)
h = tf.keras.layers.Dense(
observations,
units=hidden_layer_size,
activation='relu',
kernel_initializer = 'glorot_uniform'
)
I get this error if i use it
TypeError: __init__() got multiple values for argument 'units'
How i should use the placeholder/Input in this case?
Upvotes: 1
Views: 243
Reputation: 56377
Keras layers are not used as tf.layers
, they are callable instead of passing a tensor as the first parameter, so it should be:
observations = tf.keras.Input(
shape = [ None, OBSERVATIONS_SIZE ],
dtype = tf.float32
)
h = tf.keras.layers.Dense(
units=hidden_layer_size,
activation='relu',
kernel_initializer = 'glorot_uniform'
)(observations)
Upvotes: 2