Reputation: 53
I have Input data include 48 or 52( this number is multiple of 4) and 3 outputs. For inputs are similar below: 1.34772 1.35783 1.35937 1.35158 1.33009 And Output -1,108,128 First output always is -1 or 1 and second, third output integer between 80,140. I like to train NN model that calculates all weights, biases,... according to this inputs and outputs. Sample Input and output data AX,AY and AZ are my outputs. Is that possible use Tensorflow for training such data in same time for 3 outputs? Regards,
Upvotes: 1
Views: 6375
Reputation: 1829
The simplest way that you can try is to output 3 values from the deep learning model. I have given below a sample code with the comments where necessary.
import tensorflow as tf
N_OUTPUTS = 3
N_INPUTS = 48
N_HIDDEN_UNITS = # Define here
N_EPOCHS = # define here
input = tf.placeholder(tf.float32, shape=[None, N_INPUTS], name='input') # input here
outputs = tf.placeholder(tf.float32, shape=[None, N_OUTPUTS], name='output') # one sample is something like[Ax,Ay,Az]
# one hidden layer with 3 outputs
W = {
'hidden': tf.Variable(tf.random_normal([N_INPUTS, N_HIDDEN_UNITS])),
'output': tf.Variable(tf.random_normal([N_HIDDEN_UNITS, N_OUTPUTS]))
}
biases = {
'hidden': tf.Variable(tf.random_normal([N_HIDDEN_UNITS], mean=1.0)),
'output': tf.Variable(tf.random_normal([N_OUTPUTS]), mean=1.0)
}
hidden = tf.matmul(input, W['hidden']) + biases['hidden'] # hidden layer
output_ = tf.matmul(hidden, W['output']) + biases['output'] # outputs
cost = tf.reduce_mean(tf.square(output_ - outputs)) # calculates the cost
optimizer = tf.train.GradientDescentOptimizer(0.001).minimize(cost) # optimazer
with tf.Session() as session:
session.run(tf.global_variables_initializer())
for epoch in range(N_EPOCHS):
# _ = session.run([optimizer],feed_dict={input: , outputs : }) should feed input and output as [Ax,Ay,Az]
Above, I have created an NN model with just one hidden layer and then outputs 3 values ([Ax, Ay, Az]).
However, you can try something like above model if your [Ax, Ay, Az] are interdependent (i.e have a correlation). Otherwise, just build 3 independent models for the three outputs and train them separately.
Hope this helps.
Upvotes: 1