ValueError: malformed node or string with ast.literal_eval() when adding a Keras layer
问题 I want to build a Keras Model evaluating strings. If I do the following: from keras.models import Sequential from keras.layers import Dense model = Sequential() model.add(Dense(units=10, input_shape=(10,), activation='softmax')) It works fine. And I can see the model.summary() . But, when I add the layer with ast.literal_eval() from keras.models import Sequential from keras.layers import Dense import ast model = Sequential() code = "model.add( Dense( input_shape=(10,), units=10, activation=