XMUNLP / Tagger

Deep Semantic Role Labeling with Self-Attention
BSD 3-Clause "New" or "Revised" License
305 stars 86 forks source link

维度不匹配问题 #15

Closed alexnotes closed 6 years ago

alexnotes commented 6 years ago

初始化时,运行报错: InvalidArgumentError (see above for traceback): logits and labels must be same size: logits_size=[4080,105] labels_size=[3978,105] [[Node: tagger/softmax_cross_entropy_with_logits_sg = SoftmaxCrossEntropyWithLogits[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](tagger/softmax_cross_entropy_with_logits_sg/Reshape, tagger/softmax_cross_entropy_with_logits_sg/Reshape_1)]] [[Node: training/global_norm_2/global_norm/_2135 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_9328_training/global_norm_2/global_norm", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

数据集:conll2005 embeddings: glove 200d

Playinf commented 6 years ago

请提供更多的信息,这些信息不足以确定问题的位置。比如运行命令等等。

alexnotes commented 6 years ago

请提供更多的信息,这些信息不足以确定问题的位置。比如运行命令等等。

数据:

  1. 生成数据
    cat conll05.train.txt conll05.devel.txt conll05.test.wsj.txt > all.txt
  2. 预处理
    python ./scripts/build_vocab.py --limit 200000 --lower --input ./data/conll05/input/all.txt --output ./data/conll05/tfrecord
  3. 分别使用如下命令生成 train、devel、test 三种数据的 tfrecord 格式数据;
    python ./scripts/input_converter.py --input_path ./data/conll05/input/conll05.train.txt --output_name conll05.train --output_dir ./data/conll05/tfrecord --vocab ./data/conll05/tfrecord/vocab.txt ./data/conll05/tfrecord/label.txt --num_shards 1
  4. 训练模型
    
    #!/usr/bin/env bash

TAGGERPATH=~/srl/self-attention_srl SRLPATH=$TAGGERPATH/data/srlconll-1.1 DATAPATH=$TAGGERPATH/data/conll05 EMBEDDINGPATH=$DATAPATH/glove TFRECORDPATH=$DATAPATH/tfrecord

export PERL5LIB="$SRLPATH/lib:$PERL5LIB" export PATH="$SRLPATH/bin:$PATH"

python $TAGGERPATH/main.py train \ --data_path $TFRECORDPATH/ \ --model_dir train --model_name deepatt \ --vocab_path $TFRECORDPATH/vocab.txt $TFRECORDPATH/label.txt \ --emb_path $EMBEDDINGPATH/glove.6B.200d.txt \ --model_params=feature_size=100,hidden_size=200,filter_size=800,residual_dropout=0.2,num_hidden_layers=10,attention_dropout=0.1,relu_dropout=0.1 \ --training_params=batch_size=4096,eval_batch_size=1024,optimizer=Adadelta,initializer=orthogonal,use_global_initializer=false,initializer_gain=1.0,train_steps=600000,learning_rate_decay=piecewise_constant,learning_rate_values=[1.0,0.5,0.25],learning_rate_boundaries=[400000,500000],device_list=[0],clip_grad_norm=1.0 \ --validation_params=script=eva.sh


运行第四步的代码就会报错了,求解决~ 另外,楼主我给你的 playinf@stu.xmu.edu.cn 发了邮件了
EricLingRui commented 6 years ago

楼上的妹子,可不可以给我发一份conll2005,lingrui.ai@outlook.com。非常感谢了。我在相关网址上没找到文本,只有标签。

Playinf commented 6 years ago

@kisslotus 你提供的训练命令有错误,用200d的GloVE向量feature_size应该设置为200,hidden_size应该设置为400才对,相应的filter_size一般设置为hidden_size的4倍,即1600。

alexnotes commented 6 years ago

楼上的妹子,可不可以给我发一份conll2005,lingrui.ai@outlook.com。非常感谢了。我在相关网址上没找到文本,只有标签。

按照这个步骤 https://github.com/luheng/deep_srl 就可以得到 conll 2005 数据集了