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

Keras Compatibility with Present Version (2.2.4) #1

Open
zafarmah92 opened this issue Oct 4, 2018 · 0 comments
Open

Keras Compatibility with Present Version (2.2.4) #1

zafarmah92 opened this issue Oct 4, 2018 · 0 comments

Comments

@zafarmah92
Copy link

zafarmah92 commented Oct 4, 2018

Hi ,

I am trying to re-run the code but due to keras change of version I am unable to do such .

My problem here is with Model.py file in the function " build_icm_model ( ... ) "

Below the merge operation is performed but mode = that we can create the custom lambda operations, but in the updated keras this functionality is not longer available

can you kindly take a look how i can reproduce the merge and lambda operation below for l_i , loss0 and loss
Also what exactly the operation is performed here, would be great

Many thanks


def build_icm_model(state_shape, action_shape, lmd=1.0, beta=0.01):
    s_t0 = Input(shape=state_shape, name="state0")
    s_t1 = Input(shape=state_shape, name="state1")
    a_t = Input(shape=action_shape, name="action")
    reshape = Reshape(target_shape=(1,) + state_shape)
    fmap = build_feature_map((1,) + state_shape)
    f_t0 = fmap(reshape(s_t0))
    f_t1 = fmap(reshape(s_t1))
    act_hat = inverse_model()(f_t0, f_t1)
    f_t1_hat = forward_model()(f_t0, a_t)
    r_in = merge([f_t1, f_t1_hat], mode=lambda x: 0.5 * K.sum(K.square(x[0] - x[1]), axis=-1),
                 output_shape=(1,), name="reward_intrinsic")
    l_i = merge([a_t, act_hat], mode=lambda x: -K.sum(x[0] * K.log(x[1] + K.epsilon()), axis=-1),
                output_shape=(1,))
    loss0 = merge([r_in, l_i], mode=lambda x: beta * x[0] + (1.0 - beta) * x[1], output_shape=(1,))
    rwd = Input(shape=(1,))
    loss = merge([rwd, loss0], mode=lambda x: (-lmd * x[0].T + x[1]).T, output_shape=(1,))
    return Model([s_t0, s_t1, a_t, rwd], loss)

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