Skip to content

Instantly share code, notes, and snippets.

@VictorSaenger
Last active September 10, 2023 15:19
Show Gist options
  • Select an option

  • Save VictorSaenger/5488c718f039de7fd14c9886332da616 to your computer and use it in GitHub Desktop.

Select an option

Save VictorSaenger/5488c718f039de7fd14c9886332da616 to your computer and use it in GitHub Desktop.
#Choose optimizer:
optim = optimizers.Adam(lr=0.00015)
# create NN for news clissification:
news_DNN = Sequential()
news_DNN.add(Dense(40, input_dim=512, activation = 'relu',kernel_regularizer=l2(0.1)))
news_DNN.add(Dropout(0.25))
news_DNN.add(Dense(40, activation = 'relu',kernel_regularizer=l2(0.1)))
news_DNN.add(Dropout(0.25))
# Output layer with multiclass activation function:
news_DNN.add(Dense(4,activation='softmax'))
# Compile model:
news_DNN.compile(loss='sparse_categorical_crossentropy', optimizer=otim, metrics=['acc'])
@charlotteyo21

Copy link
Copy Markdown

Hi, I tried running your code based on this article (https://towardsdatascience.com/media-bias-detection-using-deep-learning-libraries-in-python-44efef4918d1) and encountered a bug which I had issues solving :'( I am referencing this for my final year project and would like to seek your advice on this!

Line 16 had a NameError when using 'otim' and NotImplementedError when using 'optim'
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment