"Problem on 2D Convolution Neural Networks (channels_first, channels_last not defined)"

a_lotti1a_lotti1 Member Posts: 7 Contributor I
edited May 23 in Help
Hi,
I have a CSV dataset compost of a 301 attributes and 634336 rows.
After the windowing model, the number of attributes becomes 4816 and the number of rows becomes 39645.
In keras model I would like to pass an array of 16 rows and 301 columns and use a Convolution_2D and MaxPooling_2D.
Input_shape of keras model = (None, 1, 16,301) (batchSize, channel, height, width) following an online example with "channels_first" formatting.
When I launch the process, RapidMiner returns the following error screen:
"The execution of the python script failed. Please check your python script: NameError: name 'channels_first' is not defined (script, line 272)".
If i change the configuration to "channels_last" (None, height, width, channel) the problem 's not solve.
Keras model is compost of: convolution level 2d + maxPooling 2d + Dropout + Flatten + 2 dense levels.
Could you help me solve the problem?
I have attached the .rpm file process.
Thank you so much.



Answers

  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi @a_lotti1,

    Unfortunately, I do not come with a solution, but a workaround : 
    You can maybe adapt your process in order to use the operator(s) of the Deep Learning extension (0.9.0) (to install from MarketPlace).
    For that, you can inspire yourself of the sample process 04 S&P etc.


    I hope it helps,

    Regards,

    Lionel
    sgenzera_lotti1
  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi again @a_lotti1,

    Although your problem does not seem to be related to your data, can you share your dataset(s) ?
    In deed, how said there is surely a workaround with the Deep Learning extension and/or with a Python script (implemented in
    RapidMiner via the Execute Python operator).

    Regards,

    Lionel
    a_lotti1
  • a_lotti1a_lotti1 Member Posts: 7 Contributor I
    Hi @lionelderkrikor,
    Thank you very much for your help, now I will try the alternative solution.
    If I pass as input_shape (16.301) and use a convolution_1d and maxPooling_1d, how would data be managed within keras_model?

    Regards,
    Ale
  • a_lotti1a_lotti1 Member Posts: 7 Contributor I
    edited December 2018
    Hi again @lionelderkrikor,

    I have a problem loading the zipped dataset. RapidMiner does not charge the file.
    The file size is 68.6Mb.

    Regards,
    Ale
  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi @a_lotti1,

    Thanks to share your 2 datasets.
    Like said an alternative is to use a Python Script and I'm working on it...
    I have just two questions :
     - your datasets have no header (names of the attributes) ?
     - In this case, how to determine your label ?

    Regards,

    Lionel
  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi @a_lotti1,

    Ok by executing your process, I understood : 
    Your label is Att301 which is renamed "KP"

    Regards,

    Lionel


  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi @a_lotti1,

    I was not able to reproduce what you observe ('channels first' is not defined...) but in my case, 
    the Keras model did not produce any output (so in fine RapidMiner raises an error... :'( ).

    Anyways, like said previously one workaround is to use a Python script, so I propose you
    this process using the Keras library. :)
    To execute this process, you have to set the parameters of the Keras model and the parameters of the layers 
    at the beginning of the Python script (I planned exactly the same layers you used in your RapidMiner process).



    This Python script produces 3 outputs : 
     - the training set.
     - the test set with the "raw" (at the exit of the neural network) confidences for each class of your label + the predicted class : 

     - the evaluation of the "loss function" and of the "accuracy" (based on your test set which is already labelled) : 



    I have set 2 sample operators in order to reduce the number of examples to 1000 and 100 for respectively the training set and the test set
    (to reduce the computation time) ==> don't forget to remove/disable these 2 operators before executing the process with your whole dataset(s).
    .... but be patient with your whole dataset, I think you have to wait many and many hours.....

    The process is in attached file.

    I hope it helps,

    Regards and Merry Christmas. 

    Lionel

    sgenzer
  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 720   Unicorn
    Hi @a_lotti1,

    A little improvment of the previous process : 
    There is a 4th output : an history containing the list of successive "loss" and "accuracy" according to the "epoch" during the training phase : 


    I hope it helps,

    Regards,

    Lionel
    hughesfleming68sgenzer
Sign In or Register to comment.