Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 张量流模型中作为损失函数的快速dtw_Python_Tensorflow_Keras_Loss Function_Dtw - Fatal编程技术网

Python 张量流模型中作为损失函数的快速dtw

Python 张量流模型中作为损失函数的快速dtw,python,tensorflow,keras,loss-function,dtw,Python,Tensorflow,Keras,Loss Function,Dtw,我是一名博士生,但不是深入学习或Python方面的专家,如果我的问题很琐碎,那么很抱歉。 我要做的是使用fast dtw()作为TensorFlow模型的损失函数。(RNN) 定义函数后: def dtw_distance (x,y): distance, path=fastdtw(x, y) return distance from keras.callbacks import EarlyStopping, ModelCheckpoint earlystopper = EarlyS

我是一名博士生,但不是深入学习或Python方面的专家,如果我的问题很琐碎,那么很抱歉。 我要做的是使用fast dtw()作为TensorFlow模型的损失函数。(RNN) 定义函数后:

def dtw_distance (x,y):
  distance, path=fastdtw(x, y)
  return distance
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])
我试图用它作为损失函数来编译我的模型:

def dtw_distance (x,y):
  distance, path=fastdtw(x, y)
  return distance
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])
我收到以下错误消息: TypeError:在用户代码中:

/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
/usr/local/lib/python3.6/dist包/tensorflow/python/keras/engine/training.py:806 train\u函数*
返回步骤_函数(self、迭代器)
:2 dtw_距离*
距离,路径=fastdtw(x,y)
fastdtw/_fastdtw.pyx:78 fastdtw.\u fastdtw.fastdtw**
fastdtw/_fastdtw.pyx:222 fastdtw.\u fastdtw.\u准备\u输入
/usr/local/lib/python3.6/dist-packages/numpy/core/_-asarray.py:138-asanyarray
返回数组(a,dtype,copy=False,order=order,subok=True)
TypeError:_数组__()接受1个位置参数,但提供了2个
即使在我的函数中添加了自参数,同样的错误仍然存在。 我错过了什么

多谢各位