为什么在r中运行lstm时会出现此错误?

我正在尝试使用lstm和keras在R中建立多元预测模型。我遇到了我无法解释的长错误!

我的数据有20个预测变量和5个响应,因此很难在此处附加数据。在这里,我附上我尝试过的代码。

library(keras)
#partitioning the data and splitting
set.seed(1234)
ind <- sample(2,nrow(data),replace = T,prob = c(0.7,0.3))
training <- as.matrix(data[ind==1,1:20])
test<- as.matrix(data[ind==2,1:20])
trainingtarget <- as.matrix(data[ind==1,21:25])
testtarget<- as.matrix(data[ind==2,21:25])
#reshaping the data to 3D arrays:
xarray <- array(data = training,dim = c(nrow(training),1,20))
yarray <- array(data = trainingtarget,dim = c(nrow(trainingtarget),5))
#model:
model <- keras_model_sequential()
model %>%
  layer_lstm(units = 50,input_shape = c(1,20),batch_size  = 1) %>% 
   layer_dense(units = 1)
#compiling
model %>% 
  compile(loss = 'mae',optimizer = 'adam')
#fitting 
model %>% fit(x = xarray,y = yarray,batch_size = 1,epochs     = 10,verbose    = 1,shuffle    = FALSE)

我总是遇到不同类型的错误,这很令人沮丧:

“ C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:516:FutureWarning:传递不赞成使用(type,1)或'1type'作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint8 = np.dtype([(“ qint8”,np.int8,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:517:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_quint8 = np.dtype([(“ quint8”,np.uint8,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:518:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint16 = np.dtype([(“ qint16”,np.int16,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:519:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_quint16 = np.dtype([(“” quint16“,np.uint16,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:520:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint32 = np.dtype([(“ qint32”,np.int32,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ framework \ dtypes.py:525:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   np_resource = np.dtype([(“ resource”,np.ubyte,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:541:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint8 = np.dtype([(“ qint8”,np.int8,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:542:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_quint8 = np.dtype([(“ quint8”,np.uint8,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:543:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint16 = np.dtype([(“ qint16”,np.int16,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:544:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_quint16 = np.dtype([(“” quint16“,np.uint16,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:545:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   _np_qint32 = np.dtype([(“ qint32”,np.int32,1)]) C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorboard \ compat \ tensorflow_stub \ dtypes.py:550:FutureWarning:Passing(type,1 )或不赞成使用“ 1type”作为type的同义词;在numpy的未来版本中,它将被理解为(type,(1,))/'(1,)type'。   np_resource = np.dtype([(“ resource”,np.ubyte,1)]) 警告:tensorflow: TensorFlow contrib模块不会包含在TensorFlow 2.0中。 有关更多信息,请参见:   * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md   * https://github.com/tensorflow/addons   * https://github.com/tensorflow/io(用于与I / O相关的操作) 如果您依赖那里未列出的功能,请提出问题。

2019-11-06 15:26:31.916062:I tensorflow / core / platform / cpu_feature_guard.cc:142]您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX2 py_call_impl中的错误(可调用,dots $ args,dots $ keywords):   InvalidArgumentError:data [0] .shape = [3]不是以索引[0] .shape = [2]开头      [[{{node Adam / gradients / loss / dense_loss / Mean_grad / DynamicStitch}}]]

详细的回溯:   第780行的文件“ C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ keras \ engine \ training.py”适合     steps_name ='steps_per_epoch')   第363行的文件“ C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ keras \ engine \ training_arrays.py” model_iteration     batch_outs = f(ins_batch)   文件“ C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ keras \ backend.py”,行3292,致电     run_metadata = self.run_metadata)   文件“ C:\ Users \ MUSTAF〜1 \ DOCUME〜1 \ CONDA〜1 \ envs \ R-RETI〜1 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1458, >致电     run_metadata_ptr)“

chenyu1644 回答:为什么在r中运行lstm时会出现此错误?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3148854.html

大家都在问