LSTM与Keras:输入' ref' '分配'操作需要输入l值

时间:2018-03-19 10:33:32

标签: python tensorflow deep-learning keras lstm

我想用keras运行一个lstm。我有5个类进行分类,编码为一个热门标签。

这是我的模特:

model = Sequential()
model.add(Embedding(10000, 32))
model.add(LSTM(64, dropout_W=0.2, dropout_U=0.2))
model.add(Dense(5, activation='sigmoid'))

model.compile(loss='categorical_crossentropy',
              optimizer='rmsprop',
              metrics='acc')

model.fit(xtrain, ytrain, batch_size=128, nb_epoch=10,validation_split=0.2)

但我收到以下错误:

  

TypeError:输入' ref' '分配'操作需要l值输入

以下是错误日志:

  

TypeError Traceback(最近一次调用   最后)in()         6 n_epochs = 10         7   ----> 8 history = model.fit(train_encoded,train_labels_lstm,batch_size = bs,nb_epoch = n_epochs,validation_split = 0.2)

     适合的

〜\ Anaconda3 \ lib \ site-packages \ keras \ models.py(self,x,y,   batch_size,epochs,verbose,callbacks,validation_split,   validation_data,shuffle,class_weight,sample_weight,initial_epoch,   steps_per_epoch,validation_steps,** kwargs)       961 initial_epoch = initial_epoch,       962 steps_per_epoch = steps_per_epoch,    - > 963 validation_steps = validation_steps)       964       965 def评估(自我,x =无,y =无,

     

〜\ Anaconda3 \ lib \ site-packages \ keras \ engine \ training.py in fit(self,x,   y,batch_size,epochs,verbose,callbacks,validation_split,   validation_data,shuffle,class_weight,sample_weight,initial_epoch,   steps_per_epoch,validation_steps,** kwargs)1680其他:
  1681 ins = x + y + sample_weights    - > 1682 self._make_train_function()1683 f = self.train_function 1684

     

〜\ Anaconda3 \ lib \ site-packages \ keras \ engine \ training.py in   _make_train_function(个体经营)       988 training_updates = self.optimizer.get_updates(       989 params = self._collected_trainable_weights,    - > 990损失= self.total_loss)       991更新= self.updates + training_updates + self.metrics_updates       992#获取损失和指标。每次通话时更新权重。

     

〜\ Anaconda3 \ lib \ site-packages \ keras \ legacy \ interfaces.py in   包装器(* args,** kwargs)        89 warnings.warn('更新您对Keras 2 API的' + object_name + 90 '电话:' +签名,stacklevel = 2)   ---> 91 return func(* args,** kwargs)        92 wrapper._original_function = func        93返回包装器

     get_updates中的

〜\ Anaconda3 \ lib \ site-packages \ keras \ optimizers.py(self,   损失,参数)       255#更新累加器       256 new_a = self.rho * a +(1. - self.rho)* K.square(g)    - > 257 self.updates.append(K.update(a,new_a))       258 new_p = p - lr * g /(K.sqrt(new_a)+ self.epsilon)       259

     

〜\ Anaconda3 \ lib \ site-packages \ keras \ backend \ tensorflow_backend.py in   更新(x,new_x)       961变量x已更新。       962"""    - > 963返回tf.assign(x,new_x)       964       965

     

〜\ Anaconda3 \ lib中\站点包\ tensorflow \蟒\ OPS \ gen_state_ops.py   in assign(ref,value,validate_shape,use_locking,name)        45 result = _op_def_lib.apply_op(" Assign",ref = ref,value = value,        46 validate_shape = validate_shape,   ---> 47 use_locking = use_locking,name = name)        48返回结果        49

     

〜\ Anaconda3 \ lib中\站点包\ tensorflow \蟒\框架\ op_def_library.py   在apply_op中(self,op_type_name,name,** keywords)       615引发TypeError(       616"输入'%s' '%s'操作需要l值输入" %    - > 617(input_name,op_type_name))       618 input_types.extend(types)       619其他:

     

TypeError:输入' ref' '分配'操作需要l值输入

我应该改变什么?

0 个答案:

没有答案