Search code examples
tensorflowmachine-learningneural-networkconv-neural-networktflearn

tflearn classification with CNN (conv_1d)


I have a question about tflearn and the usage of CNN with it. I have a classification problem with n data variables (float) and m classes. I tried to implement this by using https://github.com/tflearn/tflearn/blob/master/examples/nlp/cnn_sentence_classification.py this with just my dataset. But they used an embedding, which doesn't work for me (I have uncountable many possible values for the input values, since they are float). If I just drop the line network = tflearn.embedding(network, input_dim=10000, output_dim=128), I don't have a 3-d tensor as input for the following conv_1d layer. Could anyone help me? So how can I bring my data into the right shape to apply some convolutions?

Thanks!!


Solution

  • Add an extra dimension at the end, it needs a channel dimension, like so (changed the second like, the first and third I copied for easier understanding):

    network = input_data(shape=[None, 100], name='input')
    network = tf.expand_dims(network, 2)
    branch1 = conv_1d(network, 128, 3, padding='valid', activation='relu', regularizer="L2")