Home > Back-end >  AttributeError: 'Sequential' object has no attribute 'model'
AttributeError: 'Sequential' object has no attribute 'model'

Time:06-17

from tensorflow.keras.layers import Dense, Activation
from tensorflow.keras.models import Sequential, load_model
from tensorflow.keras.optimizers import Adam

def build_dqn(lr, n_actions, input_dims, fc1_dims, fc2_dims):
    model = Sequential([
        Dense(fc1_dims, input_shape=(input_dims,)),
        Activation('relu'),
        Dense(fc2_dims),
        Activation('relu'),
        Dense(n_actions)])

    model.compile(optimizer=Adam(lr=lr), loss='mse')

    return model

I am trying to understand Double Deep Q-Learning. There is a pretty good lecture here: enter image description here

CodePudding user response:

For solving your error you can go through the below steps:

1. Install dependency for can run the env:

!pip install Box2D0
!pip install box2d-py
!pip install gym[all]
!pip install gym[Box_2D]

2. Change imports like below:

from keras.layers import Dense, Activation
from keras import Sequential
from keras.models import load_model
from tensorflow.keras.optimizers import Adam

3. Install tf-nightly: (what is tf-nightly)

!pip install tf-nightly
  • Related