我试图使用RNN(特别是LSTM)进行序列预测.但是,我遇到了可变序列长度的问题.例如,
sent_1 = "I am flying to Dubain"
sent_2 = "I was traveling from US to Dubai"
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用基于此Benchmark的简单RNN来预测当前的下一个词,以构建PTB LSTM模型.
但是,num_steps参数(用于展开到先前的隐藏状态)应该在每个Tensorflow的纪元中保持相同.基本上,由于句子的长度不同,因此无法批量处理句子.
# inputs = [tf.squeeze(input_, [1])
# for input_ in tf.split(1, num_steps, inputs)]
# outputs, states = rnn.rnn(cell, inputs, initial_state=self._initial_state)
Run Code Online (Sandbox Code Playgroud)
在这里,num_steps每个句子都需要改变我的情况.我尝试了几次黑客攻击,但似乎没有任何效果.
我在加载位于当前目录中的.gdbinit文件时遇到问题.在启动gdb时,我得到了这个:
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
warning: File "/home/user1/test/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
Run Code Online (Sandbox Code Playgroud)
我可以通过以下命令启动gdb来加载当前目录中的.gdbinit文件:
gdb …Run Code Online (Sandbox Code Playgroud) 为什么我不能使用@staticmethod装饰器使类'__call__方法静态?
class Foo(object):
@staticmethod
def bar():
return 'bar'
@staticmethod
def __call__():
return '__call__'
print Foo.bar()
print Foo()
Run Code Online (Sandbox Code Playgroud)
输出
bar
<__main__.Foo object at 0x7fabf93c89d0>
Run Code Online (Sandbox Code Playgroud)
但我希望它输出
bar
__call__
Run Code Online (Sandbox Code Playgroud) 我试图用keras使用CTC语音识别和尝试了CTC例子在这里.在该示例中,CTC Lambda层的输入是softmax层(y_pred)的输出.该Lambda层调用ctc_batch_cost内部调用Tensorflow ctc_loss,但Tensorflow ctc_loss文档说该ctc_loss函数在内部执行softmax,因此您不需要首先softmax输入.我认为正确的用法是传递inner给Lambda图层,所以你只在ctc_loss内部函数中应用softmax .我试过这个例子,但它确实有效.我应该遵循示例还是Tensorflow文档?
我正在使用GPU训练深度神经网络。如果我制作的样本太大,批处理太大或网络太深,则会出现内存不足错误。在这种情况下,有时可以制作较小的批次并仍进行训练。
是否可以计算训练所需的GPU大小并预先确定要选择的批处理大小?
更新
如果我打印网络摘要,它将显示“可训练参数”的数量。我不能从这个值估算吗?例如,将其乘以批处理大小,将梯度乘以两倍等等?
我在理解refRust中的模式时遇到了问题.我指的是https://rustbyexample.com/scope/borrow/ref.html
这是我不明白的代码:
let point = Point { x: 0, y: 0 };
let _copy_of_x = {
// `ref_to_x` is a reference to the `x` field of `point`
let Point { x: ref ref_to_x, y: _ } = point;
// Return a copy of the `x` field of `point`
*ref_to_x
};
Run Code Online (Sandbox Code Playgroud)
我得到的是最后一个let表达式(?)是某种模式匹配.所以我的理解ref ref_to_x应该等于原始0的x价值point.
但我不明白ref实际上是做什么的.当我添加这样的代码时:
println!("x: {}", point.x);
println!("ref_to_x: {}", ref_to_x);
println!("*ref_to_x: {}", *ref_to_x);
Run Code Online (Sandbox Code Playgroud)
我总是得到0,所以似乎没有区别.不知何故,我希望 …