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

Defined classifier inputs and outputs #7

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cellx/networks/classifier.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# this will be the classifier
# Building the CNN classifier:

import tensorflow as tf
from tensorflow import keras as K

from cellx import layers
quantumjot marked this conversation as resolved.
Show resolved Hide resolved

input = K.Input(shape=(2,))
encoder = layers.Encoder2D()(input)
Copy link
Contributor

@chris-soelistyo chris-soelistyo Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might perhaps be worth specifying the encoder layer when the build_classifier function is called as well, e.g.

encoder = layers.Encoder2D()
def build_classifier(shape: tuple, outputs: int, dense_filters: int = 512, encoder=encoder):
    """add docstrings :)"""
    input = K.Input(shape=shape)
    ...
    return classifier_model

seeing as it can be helpful to experiment with various instances of Encoder2D (with different numbers of layers, units per layer etc) and that would be served I think by being able to call Encoder2D outside of build_classifier and then incorporate it in after.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point @chris-soelistyo ! Why don't we save this for a follow-up PR? Perhaps you can do that once we merge this.

dense = K.layers.Dense(512, activation="relu")(encoder)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think you'll need a Flatten here:

flat = K.layers.Flatten()(encoder)
dense = ...(flat)

output = K.layers.Dense(4, activation=tf.nn.softmax)(dense)

classifier_model = K.Model(inputs=input, outputs=output)
Comment on lines +8 to +13
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this a function for now (and transition to a full model later), e.g.:

def build_classifier(shape: tuple, outputs: int, dense_filters: int = 512):
    """add docstrings :)"""
    input = K.Input(shape=shape)
    ...
    return classifier_model