是否可以并行化 python CRFSuite(https://github.com/tpeng/python-crfsuite)?我认为 CRF++ 支持并行化,所以我猜想也必须有一些钩子来启用 CRFsuite 的并行化。
如何转义要搜索的字符串中的单引号字符?
例子:
strng = "King's palace"
df.query("fieldname == %s" %(strng))
Run Code Online (Sandbox Code Playgroud)
由于引号,此查询未返回数据。逃避是没有帮助的。
def biLSTM(data, n_steps):
n_hidden= 24
data = tf.transpose(data, [1, 0, 2])
# Reshape to (n_steps*batch_size, n_input)
data = tf.reshape(data, [-1, 300])
# Split to get a list of 'n_steps' tensors of shape (batch_size, n_input)
data = tf.split(0, n_steps, data)
lstm_fw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0)
# Backward direction cell
lstm_bw_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0)
outputs, _, _ = tf.nn.bidirectional_rnn(lstm_fw_cell, lstm_bw_cell, data, dtype=tf.float32)
return outputs, n_hidden
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我调用此函数两次以创建2个双向LSTM.然后我遇到了重用变量的问题.
ValueError:变量lstm/BiRNN_FW/BasicLSTMCell/Linear/Matrix已存在,不允许.你的意思是在VarScope中设置reuse = True吗?
为了解决这个问题,我在函数中添加了LSTM定义 with tf.variable_scope('lstm', reuse=True) as scope:
这导致了一个新问题
ValueError:变量lstm/BiRNN_FW/BasicLSTMCell/Linear/Matrix不存在,不允许.你是不是要在VarScope中设置reuse = None?
请帮助解决这个问题.