我想使用tensorflow生成文本,并且一直在修改LSTM教程(https://www.tensorflow.org/versions/master/tutorials/recurrent/index.html#recurrent-neural-networks)代码来执行此操作,然而,我的初始解决方案似乎产生了废话,即使经过长时间的训练,它也没有改善.我不明白为什么.我们的想法是从零矩阵开始,然后一次生成一个单词.
这是代码,我在https://tensorflow.googlesource.com/tensorflow/+/master/tensorflow/models/rnn/ptb/ptb_word_lm.py下添加了两个函数.
发电机看起来如下
def generate_text(session,m,eval_op):
state = m.initial_state.eval()
x = np.zeros((m.batch_size,m.num_steps), dtype=np.int32)
output = str()
for i in xrange(m.batch_size):
for step in xrange(m.num_steps):
try:
# Run the batch
# targets have to bee set but m is the validation model, thus it should not train the neural network
cost, state, _, probabilities = session.run([m.cost, m.final_state, eval_op, m.probabilities],
{m.input_data: x, m.targets: x, m.initial_state: state})
# Sample a word-id and add it to the matrix and output
word_id …Run Code Online (Sandbox Code Playgroud) 我有带有数字输入的嵌套字段,但无法使验证正常工作。不确定这是否是 formik 或 yup 的问题/验证模式是如何声明的,但我会在这里开始询问。
在示例中,我有两个字段代表数字,默认为空字符串。验证适用于第一个字段,但我无法使其对嵌套字段的行为相同。当我触摸该字段但不输入任何内容时,它会返回:
social.facebook 必须是一种
number类型,但最终值是:(NaN从值中转换"")。
示例:代码沙盒
对以下 IPv6 地址使用零压缩时
2001:0DB8:0000:CD30:0000:0000:0000:0000/60
Run Code Online (Sandbox Code Playgroud)
为什么这是不正确的:
2001:DB8::CD30::/60
Run Code Online (Sandbox Code Playgroud)
...虽然这是:
2001:DB8:0:CD30::/60
Run Code Online (Sandbox Code Playgroud)