https://classroom.udacity.com/nanodegrees/nd101/parts/73a7fe8e-4354-4362-939d-a8bf2bae870d/modules/e6a4e4a1-98a9-4afe-a744-7ae6a59c01b8/lessons/7c042ed0-08e7-4138-ad78-1a8d671d5da5/concepts/5e22aa8d-9d4d-4b83-8b34-9f606d0abee4

Workspace

To open this notebook, you have two options:

  • Go to the next page in the classroom (recommended)
  • Clone the repo from Github and open the notebook IMDB_in_Keras.ipynb in the imdb_keras folder. You can either download the repository with git clone https://github.com/udacity/deep-learning.git, or download it as an archive file from this link.

My Solution -> Accuracy: 0.86116

# TODO: Build the model architecture
model = Sequential()
model.add(Dense(512, input_dim=x_train.shape[1]))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(128))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(32))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(2))
model.add(Activation('softmax'))

# TODO: Compile the model using a loss function and an optimizer.
model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

# TODO: Run the model. Feel free to experiment with different batch sizes and number of epochs.
model.fit(x_train, y_train, epochs=12, batch_size=128)

score = model.evaluate(x_test, y_test, verbose=0)
print("Accuracy: ", score[1])

Udacity Solution -> Accuracy: 0.85328

# Building the model architecture with one layer of length 100
model = Sequential()
model.add(Dense(512, activation='relu', input_dim=1000))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
model.summary()

# Compiling the model using categorical_crossentropy loss, and rmsprop optimizer.
model.compile(loss='categorical_crossentropy',
              optimizer='rmsprop',
              metrics=['accuracy'])

# Running and evaluating the model
hist = model.fit(x_train, y_train,
          batch_size=32,
          epochs=10,
          validation_data=(x_test, y_test), 
          verbose=2)

results matching ""

    No results matching ""