Recently I study tensorflow, the examples that are described in the books work, but they use the MNIST melon sets. But if I enter my micro-set data, the model does not converge. Earlier, I developed my network and it worked on small test suites not in the tensorflow library. An example of such an input is an array for example [10,20,30,40] , and an output for example [0.1,0.4,0.5] , that is, the input 4 neuron to output 3 . The model is trained, we check for input [10,20,30,40] we get [0.1,0.4,0.5] . But in practice, the model does not converge, starts learning and fades away. What is wrong with networking and input? It looks like fading gradients, but I'm not sure. How can this be fixed?
import tensorflow as tf import numpy as np from keras.models import Sequential from keras.layers import Input, Dense, Activation from sklearn import preprocessing model=Sequential() model.add(Dense(10,input_shape=(4,),activation="elu",init="uniform")) model.add(Dense(10,activation="elu",init="uniform")) model.add(Dense(3,activation="elu",init="uniform")) model.compile(loss="categorical_crossentropy", optimizer="sgd", metrics=["accuracy"]) def data(): X = np.array([[40, 80, 30, 60], [100, 40, 20, 80], [90, 190, 10, 15]]) Y = np.array([[10, 20, 30], [10, 40, 60], [80, 90,100]]) X=X/100 Y=Y/100 return X,Y x_train,Y_train=data() model.fit(x_train,Y_train,batch_size=3,epochs=300, verbose=1) a=np.array([40, 80, 30, 60])/100; predict_dataset = tf.convert_to_tensor(x_train,dtype=tf.float32) reshy =a.reshape((1,- 1)) print("test") print(reshy) prediction = model.predict(reshy) print('prediction') print(prediction) print('x_train') print(x_train) print('Y_train') print(Y_tirain) print("Привет")