3
Hello! I am building a network that should map time values to a vector containing 3 values of reagent concentrations, simulating a chemical reaction of type A->B->C. The concentration values were obtained with the Solver odeint and solving the equations numerically, thus having a data set to feed the network.
I’m using the Keras, with the following network:
model = Sequential()
model.add(Dense(1, activation='relu')) #input layer [t]
model.add(Dense(64, activation = 'relu'))
model.add(Dense(64, activation = 'relu'))
model.add(Dense(16, activation = 'relu'))
model.add(Dense(3, activation = 'relu')) #output layer [CA, CB, CC]
model.compile(loss = "mean_squared_error", optimizer = "Adam", metrics = ['mean_squared_error'])
return model
By training the network, I get the following learning curve:
However, when I will test the network for the t values used as input, using the following code:
for i in range(len(t)):
C.append(model.predict([t[i]]))
C = np.array(C)
plt.plot(t,C[:,0]);
plt.legend(['A','B','C']);
Getting the following curve:
While right would be something close to:
I would like to know what may be causing this problem, and how to resolve it. Thank you!
You are right about the use of function
mean_squared_error
? It is a problem of regression or classification?– Bernardo Lopes
As far as I’m concerned, it’s a regression problem. Basically my network should fit to a set of 3 differential equations that are generated by the mass balances of each component.
– Fernando de Come
There is little information to understand here, but apparently, your problem may be classification. If Voce expects its network to manage the outputs [CA, CB, CC], predicting whether a reaction is of type CA, CB or CC, Voce has a classification problem,
categorical_crossentropy
– Bernardo Lopes