Submitted by Constant-Cranberry29 t3_y0deqh in deeplearning

I have trained the data and the results are quite good ... but when I want to test it using other data the model that has been trained can't predict well. where is the fault

dataset A:

https://preview.redd.it/kt3xfbq40zs91.png?width=94&format=png&auto=webp&s=794b52ab5123ee31c5a7f6f610aac23e5a689c0a

Dataset B:

https://preview.redd.it/l5ixw3l90zs91.png?width=497&format=png&auto=webp&s=10a0e5f190cd5cfb1e1e9e23981f072729443509

Data Preprocessing

SmartInsole = np.array(data4test)

AvgFC = np.array(Avg)

Dataset = np.concatenate((SmartInsole, AvgFC), axis=1)

​

https://preview.redd.it/7wv3j4rf0zs91.png?width=104&format=png&auto=webp&s=390623a683a4f5a7c99152a4215288fabae2bc7b

The dataset after splitting and normalized:

​

https://preview.redd.it/4ysdurxj0zs91.png?width=702&format=png&auto=webp&s=9cb191a5a87726e7f5a25f9847aea8ed377c76d3

I am working with Keras and trying to fit a resnet50 to the data just to evaluate it. Below is the my resnet model structure:

Below is identity blok:

​

https://preview.redd.it/3be0yx6o0zs91.png?width=698&format=png&auto=webp&s=1724cf2e8b9f9a0991b1708a3c3c93d6e2cfd8ef

Below is dens_block:

​

https://preview.redd.it/70508euq0zs91.png?width=516&format=png&auto=webp&s=dbff7ef02057f76c505013abf81d4b2e566c8a33

Resnet50 model:

​

https://preview.redd.it/f5yf8z6t0zs91.png?width=568&format=png&auto=webp&s=2d92c110712a7b80f56c62aef56a39402087bad0

Essentially, I am fitting the model to each dataset as follows:

import datetime from tensorflow.keras 
import layers,models  

model = ResNet50Regression()  
model.compile(loss='mae', optimizer=Adam(learning_rate=0.0001), metrics=['mse']) model.summary()  
starttime = datetime.datetime.now()  
history = model.fit(X_train, y_train, epochs=2000, batch_size=64,  verbose=2, validation_split=0.1) 
endtime = datetime.datetime.now()

This is the result of prediction of training data using X_test data, the results of the prediction are quite good

https://preview.redd.it/qqx644j31zs91.png?width=888&format=png&auto=webp&s=6df1cdb57910df5ab0ba66272188f065bb8e5067

This prediction results using other data, it can be seen from the prediction results that the model is not able to predict optimally. how to make the model work well even though it uses other data

​

https://preview.redd.it/iyweak351zs91.png?width=888&format=png&auto=webp&s=10d54683cf769367d4b88c21bfbdcfb8aa29ab0f

Note : the total of Dataset is 3000,then I split it for training and testing data Data for Training is 2450 and data for testing is 550

3

Comments

You must log in or register to comment.

_Arsenie_Boca_ t1_irr84f2 wrote

I guess this is timeseries forecasting. You should think about the lookahead. Probably, during training, the model only has to predict the next point, while during testing, it has to predict many values autoregressively

2

Constant-Cranberry29 OP t1_irr8eo4 wrote

>I guess this is timeseries forecasting. You should think about the lookahead. Probably, during training, the model only has to predict the next point, while during testing, it has to predict many values autoregressively

what should I do? should I change the model structure or use another model?

1

_Arsenie_Boca_ t1_irr9bb4 wrote

No this is not a modelling issue. It actually isnt a real issue at all. Predicting a very long trajectory is simply very hard. At each timestep, a slight error will occur which will exponentiate, even if the error per timestep is marginal. Imagine being asked to predict a certain stock price. Given some expertise and current information, you might be able to do it for tomorrow, but can you do it precisely for the next year?

1

Constant-Cranberry29 OP t1_irra20x wrote

then is there any suggestion for me so that the model I have made can predict properly?

1

_Arsenie_Boca_ t1_irrcmwh wrote

If all you want to see is the two curves close to each other, I guess you could size up the model, so that it overfits terribly. But is that really desirable?

If my assumption that you predict the whole graph autoregressively is correct, then I believe it works just fine. You should check the forecast horizon and think about what it is you want to achieve in the end

1

Constant-Cranberry29 OP t1_irreagz wrote

Do you mean I need size up in this part?

def ResNet50Regression():

`Res_input = layers.Input(shape=(178,))`

# 128

`width = 128`



`x = dens_block(Res_input,width)`

`x = identity_block(x,width)`

`x = identity_block(x,width)`



`x = dens_block(x,width)`

`x = identity_block(x,width)`

`x = identity_block(x,width)`



`x = dens_block(x,width)`

`x = identity_block(x,width)`

`x = identity_block(x,width)`



`x = layers.BatchNormalization()(x)`

`x = layers.Dense(1,activation='linear')(x)`

`model = models.Model(inputs=Res_input, outputs=x)`



`return model`
1