Options

I want to Implement Deep Learning using Keras on macOS. I tried to run Iris sample for deep learing.

malik_waqar84malik_waqar84 Member Posts: 4 Contributor I
edited March 2019 in Help

Answers

  • Options
    varunm1varunm1 Moderator, Member Posts: 1,207 Unicorn
    Hello @malik_waqar84

    The keras extension in RM is not stable. RM has Deep learning extension which can be used for CNN and LSTM (Deep networks). This deep learning is available in market place and runs on DL4j instead of Keras. This also comes with sample processes for your understanding.

    If you want to try keras. please look at the below thread where jpuente gave clear settings that are needed to run keras extension. You should use exact versions of packages suggested in the below thread.

    https://community.rapidminer.com/discussion/comment/54662#Comment_54662
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

  • Options
    sgenzersgenzer Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    @malik_waqar84 ok just curious...
    • did you see this banner appear when you restarted RM after downloading Keras from the marketplace? You should have...



    • which hyperlink did you go to (or did you just close it)?
    • how can we make this process better so that you find this information?
    The reasons I ask are because:
    • I make and maintain these banners
    • This banner was specifically designed to help users like yourself NOT get that error.

    Thanks!

    Scott
  • Options
    malik_waqar84malik_waqar84 Member Posts: 4 Contributor I
    Hello. Thanks for sharing the thread and now i have run the keras sample codes successfully. But now when i add some convolutional and pooling layer i get an error message "input 0 is incompatible with layer conv1d_2 expected ndim 3 found ndim 2". please help me to solve this issue
    thanks to you in advance
  • Options
    malik_waqar84malik_waqar84 Member Posts: 4 Contributor I
    i have used the option of "Get the deep learning beta".
  • Options
    varunm1varunm1 Moderator, Member Posts: 1,207 Unicorn
    edited March 2019
    Hi @malik_waqar84

    Yes, there is an issue with the shapes of CNN networks in keras extension. Even I tried many and nothing worked out. As this extension is kind of outdated due to new extension (Deep Learning) availability there is no much support for this. 

    I left keras extension and used python to develop models before the new deep learning extension was deployed by RM.

    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

  • Options
    malik_waqar84malik_waqar84 Member Posts: 4 Contributor I
    Can you please guide me how to use CNN in python for iris dataset. I need some example or tutorial to implement iris dataset as i have modified my datset according to iris dataset. i will be extremely thankful to you, if you please guide me and help me.
  • Options
    varunm1varunm1 Moderator, Member Posts: 1,207 Unicorn
    edited March 2019
    Hi @malik_waqar84

    Did you download the new "Deep learning extension" in RM which has Iris data as an example provided? Screenshot provided in this post.

    I applied to CNN in this IRIS data set sample and it worked well. Please see code below. For this code to work you should download the "Deep Learning" extension.

    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process" origin="GENERATED_SAMPLE">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="9.2.000" expanded="true" height="68" name="Retrieve Iris" origin="GENERATED_SAMPLE" width="90" x="45" y="238">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
            <description align="center" color="transparent" colored="false" width="126">Loading Data</description>
          </operator>
          <operator activated="true" class="split_data" compatibility="9.2.000" expanded="true" height="103" name="Split Data" origin="GENERATED_SAMPLE" width="90" x="179" y="238">
            <enumeration key="partitions">
              <parameter key="ratio" value="0.8"/>
              <parameter key="ratio" value="0.2"/>
            </enumeration>
            <parameter key="sampling_type" value="automatic"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
            <description align="center" color="transparent" colored="false" width="126">Split data into train and test set</description>
          </operator>
          <operator activated="true" class="deeplearning:dl4j_sequential_neural_network" compatibility="0.9.000" expanded="true" height="103" name="Deep Learning" origin="GENERATED_SAMPLE" width="90" x="313" y="136">
            <parameter key="loss_function" value="Multiclass Cross Entropy (Classification)"/>
            <parameter key="epochs" value="100"/>
            <parameter key="use_miniBatch" value="false"/>
            <parameter key="batch_size" value="32"/>
            <parameter key="updater" value="Adam"/>
            <parameter key="learning_rate" value="0.01"/>
            <parameter key="momentum" value="0.9"/>
            <parameter key="rho" value="0.95"/>
            <parameter key="epsilon" value="1.0E-6"/>
            <parameter key="beta1" value="0.9"/>
            <parameter key="beta2" value="0.999"/>
            <parameter key="RMSdecay" value="0.95"/>
            <parameter key="weight_initialization" value="Normal"/>
            <parameter key="bias_initialization" value="0.0"/>
            <parameter key="use_regularization" value="false"/>
            <parameter key="l1_strength" value="0.1"/>
            <parameter key="l2_strength" value="0.1"/>
            <parameter key="optimization_method" value="Stochastic Gradient Descent"/>
            <parameter key="backpropagation" value="Standard"/>
            <parameter key="backpropagation_length" value="50"/>
            <parameter key="infer_input_shape" value="true"/>
            <parameter key="network_type" value="Simple Neural Network"/>
            <parameter key="log_each_epoch" value="true"/>
            <parameter key="epochs_per_log" value="10"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
            <process expanded="true">
              <operator activated="true" class="deeplearning:dl4j_convolutional_layer" compatibility="0.9.000" expanded="true" height="68" name="Add Convolutional Layer" width="90" x="45" y="85">
                <parameter key="number_of_activation_maps" value="64"/>
                <parameter key="kernel_size" value="2.2"/>
                <parameter key="stride_size" value="1.1"/>
                <parameter key="activation_function" value="ReLU (Rectified Linear Unit)"/>
                <parameter key="use_dropout" value="false"/>
                <parameter key="dropout_rate" value="0.25"/>
                <parameter key="overwrite_networks_weight_initialization" value="false"/>
                <parameter key="weight_initialization" value="Normal"/>
                <parameter key="overwrite_networks_bias_initialization" value="false"/>
                <parameter key="bias_initialization" value="0.0"/>
              </operator>
              <operator activated="true" class="deeplearning:dl4j_pooling_layer" compatibility="0.9.000" expanded="true" height="68" name="Add Pooling Layer" width="90" x="179" y="187">
                <parameter key="Pooling Method" value="max"/>
                <parameter key="PNorm Value" value="1.0"/>
                <parameter key="Kernel Size" value="2.2"/>
                <parameter key="Stride Size" value="1.1"/>
              </operator>
              <operator activated="true" class="deeplearning:dl4j_dense_layer" compatibility="0.9.000" expanded="true" height="68" name="Add Fully-Connected Layer" origin="GENERATED_SAMPLE" width="90" x="313" y="238">
                <parameter key="number_of_neurons" value="64"/>
                <parameter key="activation_function" value="ReLU (Rectified Linear Unit)"/>
                <parameter key="use_dropout" value="false"/>
                <parameter key="dropout_rate" value="0.25"/>
                <parameter key="overwrite_networks_weight_initialization" value="false"/>
                <parameter key="weight_initialization" value="Normal"/>
                <parameter key="overwrite_networks_bias_initialization" value="false"/>
                <parameter key="bias_initialization" value="0.0"/>
                <description align="center" color="transparent" colored="false" width="126">You can choose a number of neurons to decide how many internal attributes are created.</description>
              </operator>
              <operator activated="true" class="deeplearning:dl4j_dense_layer" compatibility="0.9.000" expanded="true" height="68" name="Add Fully-Connected Layer (2)" origin="GENERATED_SAMPLE" width="90" x="313" y="85">
                <parameter key="number_of_neurons" value="3"/>
                <parameter key="activation_function" value="Softmax"/>
                <parameter key="use_dropout" value="false"/>
                <parameter key="dropout_rate" value="0.25"/>
                <parameter key="overwrite_networks_weight_initialization" value="false"/>
                <parameter key="weight_initialization" value="Normal"/>
                <parameter key="overwrite_networks_bias_initialization" value="false"/>
                <parameter key="bias_initialization" value="0.0"/>
                <description align="center" color="transparent" colored="false" width="126">The last layer needs to be setup with an activation function, that fits the problem type.</description>
              </operator>
              <connect from_port="layerArchitecture" to_op="Add Convolutional Layer" to_port="layerArchitecture"/>
              <connect from_op="Add Convolutional Layer" from_port="layerArchitecture" to_op="Add Pooling Layer" to_port="layerArchitecture"/>
              <connect from_op="Add Pooling Layer" from_port="layerArchitecture" to_op="Add Fully-Connected Layer" to_port="layerArchitecture"/>
              <connect from_op="Add Fully-Connected Layer" from_port="layerArchitecture" to_op="Add Fully-Connected Layer (2)" to_port="layerArchitecture"/>
              <connect from_op="Add Fully-Connected Layer (2)" from_port="layerArchitecture" to_port="layerArchitecture"/>
              <portSpacing port="source_layerArchitecture" spacing="0"/>
              <portSpacing port="sink_layerArchitecture" spacing="0"/>
              <description align="left" color="gray" colored="true" height="169" resized="true" width="277" x="462" y="130">Since we have a multi-class problem, we want probabilities for all possible class values. Therefore choose &amp;quot;softmax&amp;quot; as an activation function.&lt;br&gt;&lt;br&gt;The number of neurons of the last layer needs to reflect the number of possible class values. For iris, this is three.</description>
              <description align="center" color="yellow" colored="true" height="254" resized="true" width="189" x="60" y="45">First Hidden Layer</description>
              <description align="center" color="yellow" colored="false" height="254" resized="true" width="189" x="264" y="45">Output Layer</description>
            </process>
            <description align="center" color="transparent" colored="true" width="126">Open the Deep Learning operator by double-clicking on it, to discovere the layer setup.</description>
          </operator>
          <operator activated="true" class="apply_model" compatibility="9.2.000" expanded="true" height="82" name="Apply Model" origin="GENERATED_SAMPLE" width="90" x="447" y="238">
            <list key="application_parameters"/>
            <parameter key="create_view" value="false"/>
          </operator>
          <operator activated="true" class="performance_classification" compatibility="9.2.000" expanded="true" height="82" name="Performance" origin="GENERATED_SAMPLE" width="90" x="581" y="238">
            <parameter key="main_criterion" value="first"/>
            <parameter key="accuracy" value="true"/>
            <parameter key="classification_error" value="false"/>
            <parameter key="kappa" value="false"/>
            <parameter key="weighted_mean_recall" value="false"/>
            <parameter key="weighted_mean_precision" value="false"/>
            <parameter key="spearman_rho" value="false"/>
            <parameter key="kendall_tau" value="false"/>
            <parameter key="absolute_error" value="false"/>
            <parameter key="relative_error" value="false"/>
            <parameter key="relative_error_lenient" value="false"/>
            <parameter key="relative_error_strict" value="false"/>
            <parameter key="normalized_absolute_error" value="false"/>
            <parameter key="root_mean_squared_error" value="false"/>
            <parameter key="root_relative_squared_error" value="false"/>
            <parameter key="squared_error" value="false"/>
            <parameter key="correlation" value="false"/>
            <parameter key="squared_correlation" value="false"/>
            <parameter key="cross-entropy" value="false"/>
            <parameter key="margin" value="false"/>
            <parameter key="soft_margin_loss" value="false"/>
            <parameter key="logistic_loss" value="false"/>
            <parameter key="skip_undefined_labels" value="true"/>
            <parameter key="use_example_weights" value="true"/>
            <list key="class_weights"/>
            <description align="center" color="transparent" colored="false" width="126">Calculate model performance</description>
          </operator>
          <connect from_op="Retrieve Iris" from_port="output" to_op="Split Data" to_port="example set"/>
          <connect from_op="Split Data" from_port="partition 1" to_op="Deep Learning" to_port="training set"/>
          <connect from_op="Split Data" from_port="partition 2" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Deep Learning" from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
          <connect from_op="Performance" from_port="performance" to_port="result 1"/>
          <connect from_op="Performance" from_port="example set" to_port="result 2"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
          <portSpacing port="sink_result 3" spacing="0"/>
          <description align="center" color="yellow" colored="false" height="105" resized="false" width="180" x="45" y="40">Creating a simple neural network with one hidden layer and an output layer.</description>
          <description align="center" color="green" colored="true" height="331" resized="true" width="275" x="285" y="79">Iris is a multi-class classification problem, therefore the network loss is set to &amp;quot;multiclass cross entropy&amp;quot;.</description>
        </process>
      </operator>
    </process>
    



    For Deep learning using keras in python, there are many sample programs available in Kaggle. One such CNN network is in the below link.
    https://www.kaggle.com/moghazy/guide-to-cnns-with-data-augmentation-keras
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

Sign In or Register to comment.