Keras and LSTM configuration problem

User: "ipasha"
New Altair Community Member
Updated by Jocelyn

I am experiencing problem configuring Keras/LSTM model. I get the following error dueing execution

Execution of Python script failed

Please check your Python script: ValueError:

Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (212, 41) (script, line 295)

 

LayerListIOObject

LSTM(41, input_shape=var_input_shape, batch_input_shape=(1, 2, 17), activation='tanh', recurrent_activation='tanh', use_bias=True, kernel_initializer=glorot_uniform(seed=None), recurrent_initializer=glorot_uniform(seed=None), bias_initializer=Zeros(), unit_forget_bias=True, kernel_regularizer=None,recurrent_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, recurrent_constraint=None, bias_constraint=None, dropout=0.0, recurrent_dropout=0.0, stateful=True, unroll=False, implementation=0),

Dense(2, activation='softmax', use_bias=True, kernel_initializer=glorot_uniform(seed=None), bias_initializer=Zeros(), kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None)

<?xml version="1.0" encoding="UTF-8"?><process version="8.0.001">

<context>

<input/>

<output/>

<macros/>

</context>

<operator activated="true" class="process" compatibility="8.0.001" expanded="true" name="Process">

<process expanded="true">

<operator activated="true" class="read_excel" compatibility="8.0.001" expanded="true" height="68" name="Read Excel" width="90" x="45" y="34">

<parameter key="excel_file" value="C:\Users\ipasha\.RapidMiner\repositories\Local Repository\TextMining\Data\State.xlsx"/>

<list key="annotations"/>

<list key="data_set_meta_data_information"/>

</operator>

<operator activated="true" class="set_role" compatibility="8.0.001" expanded="true" height="82" name="Set Role" width="90" x="179" y="34">

<parameter key="attribute_name" value="PortState"/>

<parameter key="target_role" value="label"/>

<list key="set_additional_roles">

<parameter key="PortState" value="label"/>

</list>

</operator>

<operator activated="true" class="split_data" compatibility="8.0.001" expanded="true" height="103" name="Split Data" width="90" x="313" y="187">

<enumeration key="partitions">

<parameter key="ratio" value="0.9"/>

<parameter key="ratio" value="0.1"/>

</enumeration>

</operator>

<operator activated="true" class="keras:sequential" compatibility="1.0.003" expanded="true" height="166" name="Keras Model" width="90" x="447" y="34">

<parameter key="input shape" value="(41,)"/>

<parameter key="loss" value="sparse_categorical_crossentropy"/>

<parameter key="optimizer" value="Adam"/>

<enumeration key="metric"/>

<parameter key="epochs" value="128"/>

<enumeration key="callbacks">

<parameter key="callbacks" value="TensorBoard(log_dir='./logs', histogram_freq=0, write_graph=True, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None)"/>

</enumeration>

<process expanded="true">

<operator activated="true" class="keras:recurrent_layer" compatibility="1.0.003" expanded="true" height="82" name="Add Recurrent Layer" width="90" x="112" y="34">

<parameter key="layer_type" value="LSTM"/>

<parameter key="no_units" value="41"/>

<parameter key="recurrent_activation" value="tanh"/>

<parameter key="stateful" value="true"/>

</operator>

<operator activated="true" class="keras:core_layer" compatibility="1.0.003" expanded="true" height="82" name="Add Core Layer (2)" width="90" x="447" y="34">

<parameter key="no_units" value="2"/>

<parameter key="activation_function" value="'softmax'"/>

<parameter key="dims" value="1.1"/>

</operator>

<connect from_op="Add Recurrent Layer" from_port="layers 1" to_op="Add Core Layer (2)" to_port="layers"/>

<connect from_op="Add Core Layer (2)" from_port="layers 1" to_port="layers 1"/>

<portSpacing port="sink_layers 1" spacing="0"/>

<portSpacing port="sink_layers 2" spacing="0"/>

</process>

</operator>

<operator activated="true" class="keras:apply" compatibility="1.0.003" expanded="true" height="82" name="Apply Keras Model" width="90" x="581" y="187"/>

<connect from_op="Read Excel" from_port="output" to_op="Set Role" to_port="example set input"/>

<connect from_op="Set Role" from_port="example set output" to_op="Split Data" to_port="example set"/>

<connect from_op="Split Data" from_port="partition 1" to_op="Keras Model" to_port="training set"/>

<connect from_op="Split Data" from_port="partition 2" to_op="Apply Keras Model" to_port="unlabelled data"/>

<connect from_op="Keras Model" from_port="model" to_op="Apply Keras Model" to_port="model"/>

<connect from_op="Apply Keras Model" from_port="labelled data" to_port="result 1"/>

<portSpacing port="source_input 1" spacing="0"/>

<portSpacing port="sink_result 1" spacing="0"/>

<portSpacing port="sink_result 2" spacing="0"/>

</process>

</operator>

</process>

 

What configuration change do I need to fix this problem?

 

Thanks

Find more posts tagged with