I'm a PhD student but not an expert in deep learning nor Python, so sorry if my question is trivial. What I'm trying to do is to use the fast dtw (https://pypi.org/project/fastdtw/) as a loss function for my TensorFlow model. (RNN) After defining the function:
def dtw_distance (x,y):
distance, path=fastdtw(x, y)
return distance
I'm trying to compile my model with it as a loss function:
from keras.callbacks import EarlyStopping, ModelCheckpoint
earlystopper = EarlyStopping(patience=10, verbose=1,monitor='loss')
checkpointer = ModelCheckpoint('model-dsbowl2018-1.h5', verbose=1, save_best_only=True,monitor='loss')
results = model.fit(train_av, train_ap, validation_split=0.1, batch_size=10, epochs=100,callbacks=[earlystopper, checkpointer])
I have the following error message: TypeError: in user code:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:806 train_function *
return step_function(self, iterator)
<ipython-input-45-aacde9207c50>:2 dtw_distance *
distance, path=fastdtw(x, y)
fastdtw/_fastdtw.pyx:78 fastdtw._fastdtw.fastdtw **
fastdtw/_fastdtw.pyx:222 fastdtw._fastdtw.__prep_inputs
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py:138 asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
TypeError: __array__() takes 1 positional argument but 2 were given
Even by adding a self argument to my function, the same error persists. What Am I missing here ?
Thank you