0
$\begingroup$

I am trying to do a multi output regression using tensorflow. I have got a dataset in Excel which includes a column of input points and 2 columns of output.You can see it here.

I coverted all numbers to numpy objects. And I am trying to do a basic regression but accuracy is always 1.0, I also want to draw graph but dunno where to start. Could Anyone please help? My code is here:

import os
import numpy as np
import tensorflow as tf
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from keras.models import Sequential
from keras.layers import Dense
from keras.activations import relu


training_data = pd.read_excel(r'C:\Users\lenovo\Desktop\Yeni klasör\training_data.xlsx',sheet_name="i1-o2")
training_data_X = training_data['i1']
traindataX = np.array(training_data_X)
training_data_Y = training_data[['o1','o2']]
traindataY = np.array(training_data_Y)
testing_data = data = pd.read_excel(r'C:\Users\lenovo\Desktop\Yeni klasör\testing_data.xlsx',sheet_name="i1-o2")
testing_data_X = testing_data['i1']
testing_data_Y = testing_data[['o1','o2']]
testdataX = np.array(testing_data_X)
testdataY = np.array(testing_data_Y)

model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(128,activation=tf.nn.tanh))
model.add(tf.keras.layers.Dense(128,activation=tf.nn.tanh))
model.add(tf.keras.layers.Dense(2))

model.compile(optimizer='adam',
              loss='mean_squared_error',
              metrics=['accuracy'])
model.fit(traindataX,traindataY,epochs=500)

val_loss,val_acc = model.evaluate(testdataX,testdataY)
print(val_loss,val_acc)
$\endgroup$
1
$\begingroup$

You are in a regression setting, where accuracy is meaningless (it is meaningful only in classification settings).

Simply remove the metrics=['accuracy'] argument from your model compilation, so that model.evaluate returns the loss only (discard also val_acc).

See the SO thread What function defines accuracy in Keras when the loss is mean squared error (MSE)? for more details.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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