#!/bin/bash
# This is our first script.
#!/bin/bash
for num in 1 2 3
do
for char in 0 1 2 3 4 5 6 7 8 9
do
echo $num $char
trainDT="lin"${num}"train_"${char}".txt"
testDT="lin"${num}"val_"${char}".txt"
cat $trainDT>ijcnn1r.txt
cat $testDT>ijcnn1t.txt
echo $(file ijcnn1r.txt)
echo $(./libFM -task r -method mcmc -train ijcnn1r.txt -test ijcnn1t.txt -iter 100 -dim ‘1,1,2’ -out output${num}${char}.libfm)
done
done
但上述代码是不行的,接着往下看!
注意到能使用libFM 下运行txt 文件单纯是
ijcnn1r.txt: ASCII text
但是由于
ijcnn1r.txt: ASCII text, with CRLF line terminators
后面多出来的部分就导致错误。这是因为CRLF中是windows格式下的换行符,在Linux下换行符发生了改变
修改对应方法
#!/bin/bash
# This is our first script.
#!/bin/bash
for num in 1 2 3
do
for char in 0 1 2 3 4 5 6 7 8 9
do
echo $num $char
trainDT="lin"${num}"train_"${char}".txt"
testDT="lin"${num}"val_"${char}".txt"
echo $(sed -i 's/\r//' $trainDT)
echo $(sed -i 's/\r//' $testDT)
echo $(file $trainDT)
echo $(file $testDT)
echo $(./libFM -task r -method mcmc -train $trainDT -test $testDT -iter 100 -dim ‘1,1,2’ -out output${num}${char}.libfm)
done
done
完美