我在使用这个start.sh
脚本时遇到问题。 当我输入 ./start.sh
,它不起作用。 我的意思是,它没有任何错误,但它什么都不做。似乎错了shell脚本:cat
当我用VIM打开这个文件(我真的要上传的图片,但我可以,因为我只是前几天不注册这个网站) 从import sys,math,random
到print '\n'
线条 所有红色。 EOS
, 颜色正常显示。 如果我在cat
前输入#
,我的意思是,#cat <<EOS | python > target.txt
,颜色发生了变化。
所以我觉得这行:
cat <<EOS | python > target.txt
是错误的。我该如何纠正它?
#!/bin/sh
if [ "$1" = clean ]; then
rm -f *.log *.dat target.txt
exit
fi
num=1
length=1000
period=50
cat <<EOS | python > target.txt
import sys,math,random
funcs = [
lambda t : (0.8 * math.sin(t), 0.8 * math.cos(t)),
lambda t : (0.3 * math.sin(t), 0.3 * math.cos(t)),
lambda t : (0.8 * math.sin(3 * t), 0.8 * math.cos(t)),
lambda t : (0.8 * math.cos(t), 0.8 * math.sin(3 * t)),
lambda t : (0.4 * math.sin(2 * t) + 0.4, 0.8 * math.cos(t)),
lambda t : (0.4 * math.sin(2 * t) - 0.4, 0.8 * math.cos(t)),
lambda t : (0.8 * math.sin(2 * t), 0.4 * math.cos(t) + 0.4),
lambda t : (0.8 * math.sin(2 * t), 0.4 * math.cos(t) - 0.4),
lambda t : (0.4 * math.cos(t) + 0.4, 0.8 * math.sin(2 * t)),
lambda t : (0.4 * math.cos(t) - 0.4, 0.8 * math.sin(2 * t)),
lambda t : (0.8 * math.cos(t), 0.4 * math.sin(2 * t) + 0.4),
lambda t : (0.8 * math.cos(t), 0.4 * math.sin(2 * t) - 0.4),
lambda t : (0.4 * math.sin(t) + 0.4, 0.8 * math.cos(t)),
lambda t : (0.4 * math.sin(t) - 0.4, 0.8 * math.cos(t)),
lambda t : (0.8 * math.sin(t), 0.4 * math.cos(t) - 0.4),
lambda t : (0.8 * math.sin(t), 0.4 * math.cos(t) + 0.4),
lambda t : (0.8 * math.sin(t), 0.8 * math.cos(2 * t)),
lambda t : (0.8 * math.sin(t), -0.8 * math.cos(2 * t)),
lambda t : (0.8 * math.cos(2 * t), 0.8 * math.sin(t)),
lambda t : (-0.8 * math.cos(2 * t), 0.8 * math.sin(t)),
lambda t : (0.3 * math.sin(t) + 0.5, 0.3 * math.cos(t) + 0.5),
lambda t : (0.3 * math.sin(t) + 0.5, 0.3 * math.cos(t) - 0.5),
lambda t : (0.3 * math.sin(t) - 0.5, 0.3 * math.cos(t) + 0.5),
lambda t : (0.3 * math.sin(t) - 0.5, 0.3 * math.cos(t) - 0.5)
]
def gen_sigma():
sigma = [0.01, 0.05]
n = 0
while True:
yield sigma[n % len(sigma)]
n += 1
gen = gen_sigma()
for f in funcs:
sigma = gen.next()
for n in xrange($num):
m = random.randint(0, 1000)
for t in [x * ((2 * math.pi)/$period) for x in xrange(m, $length+m)]:
print '\t'.join([str(x + random.gauss(0, sigma)) for x in f(t)])
print '\n'
EOS
if [ x`which rnn-learn` == x ]; then
path1=../../src/rnn-learn/
else
path1=
fi
${path1}rnn-learn -c config.txt target.txt
从哪里得到这个Python脚本包裹在Bourne Shell中?我建议你与作者核对。 – Johnsyweb
如果我能做到,我做到了。但我无法与他联系。谢谢 – stacksmith