Tensorflow 2.0 Beta: Model.fit() Throws Valueerror: Arguments And Signature Arguments Do Not Match: 56 57
I'm new to machine learning. I'm trying to make a simple RNN in Tensorflow 2.0 but I'm hitting a snag. I've reduced it to a minimal example that reproduces the problem. The goal of
Solution 1:
I'm on tensorflow version 1.13.1 and no GPU, but hopefully this still fixes the problems. It seems like you are only feeding your network input data (x), but no respond data (y). So there is nothing for the model to learn. I only added the response data train_Y_dataset and test_Y_dataset. The following code worked for me in tensorflow 1.13.1, see comment for changes:
import os
import sys
import math
from random import shuffle
import numpy as np
import tensorflow as tf
from time import time as time
epochs = 200
batch_size = 32
chunk_length = 64
features = 10defmain():
train_X_dataset = np.zeros([batch_size, chunk_length, features]) + 1# add train_Y_dataset:
train_Y_dataset = np.zeros([batch_size, 1]) + 1
test_X_dataset = np.zeros([batch_size, chunk_length, features]) + 1# add test_Y_dataset:
test_Y_dataset = np.zeros([batch_size, 1]) + 1#1#with tf.device('/gpu:0'):
model = tf.keras.Sequential([
tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(
64, return_sequences=True)),
tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(32)),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model.compile(loss='mean_absolute_error',
optimizer='adam',
metrics=['accuracy'])
# add the response variable train_Y_dataset in fit
history = model.fit(x=train_X_dataset, y=train_Y_dataset, batch_size=batch_size, epochs=epochs)
# add the response variable test_Y_dataset in evaluate
test_loss, test_acc = model.evaluate(x=test_X_dataset, y=test_Y_dataset)
print('Test Loss: {}'.format(test_loss))
print('Test Accuracy: {}'.format(test_acc))
if __name__ == '__main__':
main()
Post a Comment for "Tensorflow 2.0 Beta: Model.fit() Throws Valueerror: Arguments And Signature Arguments Do Not Match: 56 57"