Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert keras Model to DDQN QNetwork? #910

Open
linfanzz opened this issue Jan 4, 2024 · 0 comments
Open

How to convert keras Model to DDQN QNetwork? #910

linfanzz opened this issue Jan 4, 2024 · 0 comments

Comments

@linfanzz
Copy link

linfanzz commented Jan 4, 2024

I have a Keras model and I want to use it as the q network for DDQN. I don't know how to do it.

def model():
    x = Input(shape=(_pkt_num, _pkt_bytes, 1))
    y = tf.reshape(x, shape=(-1, _pkt_num, _pkt_bytes, 1))
    data_format = 'channels_last'
    y1 = _text_cnn_block(y, filters=256, height=3, width=_pkt_bytes)
    y2 = _text_cnn_block(y, filters=256, height=4, width=_pkt_bytes)
    y3 = _text_cnn_block(y, filters=256, height=5, width=_pkt_bytes)
    y = layers.concatenate(inputs=[y1, y2, y3], axis=-1)
    y = layers.Flatten(data_format=data_format)(y)
    y = layers.Dense(512, activation='relu')(y)
    y = layers.Dense(256, activation='relu')(y)
    # y = layers.Dense(128, activation='relu')(y)
    y = layers.Dense(_num_class, activation='linear')(y)
    return Model(inputs=x, outputs=y)

I tried using Sequential but failed.
So what should I do? If there is one example that is the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant