0
$\begingroup$

Previously I used Sequential model for this problem, but later I read from the TensorFlow website that it is not suitable to use it. I'd like to have a NN model to predict 100+ values from the given 25 values. The code below is my previous implementation. What kind of changes should I make to achieve better results?

import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
import tensorflow

X_train, X_test, Y_train, Y_test = train_test_split( 
    inputdata, outputdata, test_size=0.2)


model = tensorflow.keras.models.Sequential()
model.add(tensorflow.keras.Input(shape=(25)))
model.add(tensorflow.keras.layers.Dense(64, activation='relu'))
model.add(tensorflow.keras.layers.Dense(103))

model.compile(loss="mean_absolute_error", optimizer="adam",
          metrics=["mean_squared_error"])
model.fit(X_train, Y_train, epochs=20)
predictions = model.predict(predict)
$\endgroup$
2
  • $\begingroup$ A sequential model is perfectly fine in total lack of any other information. Maybe you can tell us what these 25 values and 100+ values mean and what is their relationship, and a link to the place where you read that a sequential model is not suitable for this. $\endgroup$
    – noe
    Jan 4, 2023 at 10:08
  • $\begingroup$ tensorflow.org/guide/keras/sequential_model Please, see the section where it is mentioned that it is not appropriate (Any of your layers has multiple inputs or multiple outputs). Maybe I misunderstood it. Those are band values of a hyperspectral image. Those 100 values were passed through multiple processes and became 25 (values changed completely) and I need to recover the previous 100 from 25. It is a sort of compression and decompression. I can't say they have a strong relation between at this point. $\endgroup$
    – k-sky
    Jan 4, 2023 at 10:22

1 Answer 1

0
$\begingroup$

In the Tensorflow documentation that you linked, "multiple inputs/outputs", refers to multiple input/output tensors. Here you have one input tensor (of size 25) and one output tensor (of size 100+).

$\endgroup$
3
  • $\begingroup$ Thank you for the information. But what is the algorithm here? Is it backpropagation? What is it exactly? It works but I can't understand what it is. $\endgroup$
    – k-sky
    Jan 4, 2023 at 10:52
  • $\begingroup$ Yes, it's backpropagation. All the main neural network frameworks nowadays use backpropagation. $\endgroup$
    – noe
    Jan 4, 2023 at 11:08
  • $\begingroup$ Thank you very much! $\endgroup$
    – k-sky
    Jan 4, 2023 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.