2 arrays of numbers as features generating 2 numerical outputs

Hi there,

Nice to meet you.

This is my first post, if you need more information about my problem, please send me a message. I’ll answer quickly.

I’m working on a neural network to produce features of a (almost) linear line given the x and y values. The input data is a set of x and y values. The x and y values correspond to the values in this graph:

This graph represents 10 datasets. Each with 1000 x and y values. Each line has characteristics that are influenced by two numerical input features (lets say A and B). An example:

Lets say the input features are A and B. The corresponding line this will produce is from model(A,B) and consists of 1000 points.

Thus, each set has different features, A en B, each corresponding to a (slightly) different line. If you look close enough to the first image, you will see the multiple lines (=10).

What I have to do + my problem:
I have to give the model the X and Y data in order to let it the model spit out A en B. Here is the how I arranged the date as input, and I will also show the code for producing the Neural network:

Dataset (features):

Dataset (targets):



Training the model: ** Its goes wrong here… I have tried many things as you can see in the #lines, however I keep getting the same kind of error**

Dimension of input data to the model:

Type of input data to the model:

The actual lists are of type panda’s series. like:
However, I can easily change this to numpy arrays with np.asarray(…)

I’m wondering with I am doing wrong. Entering features as a list of numbers seemed tricky. Maybe my mistake is in how I’ve done it now (see tables). I see no other option but to do it this way…

Also, I can imagine that as a result of having a list of numbers as features, the input layer has to be modified to say you’re features are two lists of 1000 numbers each.

I hope you can help me. If you think you know the answer how to tackle this problem and want access to the code, please send me a message.

Kind regards,

Hi @Stijno2,

I have created a gist here please go through this and let me know if this is what you are trying to do. As I can see the error mostly because of the input shape. You have x and y values each of 1000 dimension in each row that also should be consider while feeding it to a model. Rather than feeding from dataframe you can extract from dataframe and convert to normal numpy arrays and then feed it into the network should solve your problem.

Thanks & Regards,
Sravana Neeli.

1 Like

Hi @Siva_Sravana_Kumar_N,

Thank you very much for your response. It took me a while today to orientate the data in such a way that I succeeded with the help of your code. Tensorflow saw my dataframe, even though converted to a numpy array, as simply the number of datasets with each of them having 1 column ( = not the 1000 x or y values). But well, I managed it now I think :slight_smile: ! I am now going to interpret the results and check what exactly concatenate means in Tensorflow.

I wondered why you added another layer at the last. Why don’t you immediately attach the y1 and y2 output to the last dense layer?

Thanks again!

Kind regards,

Hi @Stijno2,

Actually from your code I have seen one extra dense layer for y2_output that’s why it has an extra layer. I hope your issue is resolved.

Thanks & Regards,
Sravana Neeli.

1 Like

Sorry for my late response. Yes, you have solved my problem. Thanks again!

I am playing with tensorboard now! :blush:
Struggling with sgd optimizers since it is always showing NaN! But that’s another subject…

Kind regards,

1 Like