Skip to content

Instantly share code, notes, and snippets.

@therealnaveenkamal
Created July 22, 2021 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealnaveenkamal/bdc95c6f3890ae21014d48c630bb696a to your computer and use it in GitHub Desktop.
Save therealnaveenkamal/bdc95c6f3890ae21014d48c630bb696a to your computer and use it in GitHub Desktop.
This code is for building up the CXR Disease classification model using the Dense121 layer
model = DenseNet121(weights='densenet.hdf5', include_top=False)
model = Model(inputs=model.input, outputs=Dense(len(labels), activation="sigmoid")(GlobalAveragePooling2D()(model.output)))
model.compile(optimizer='adam', loss=calcloss(negative_freqs, positive_freqs))
fitter = model.fit(traingenerator, validation_data=valgenerator, steps_per_epoch = 1000, epochs = 50)
model.save_weights("cxr_naveen.h5")
plt.plot(fitter.history['loss'])
plt.ylabel("loss")
plt.xlabel("epoch")
plt.title("Training Loss Curve")
plt.show()
predicted_vals = model.predict(testgenerator, steps = len(testgenerator))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment