我在使用powermockito(2.0.0-beta5)验证静态方法时遇到问题,当我调用其他(也是静态)方法时,该方法被调用了一定次数。这些类已准备好在我的测试文件顶部进行测试,相关的代码片段为:
mockStatic(Tester.class);
when(Tester.staticMethod(anyString(), anyString())).thenAnswer(new FirstResponseWithText());
OtherClass.methodThatCallsTesterStaticMethod("", "", "", false, "");
verifyStatic(Tester.class, times(3));
Tester.sendFaqRequest(anyString(), anyString());
Run Code Online (Sandbox Code Playgroud)
FirstResponseWithText是扩展的类,Answer用于控制响应的顺序。我在其他地方使用过,效果很好。
我verifyStatic在行上收到以下错误:
org.mockito.exceptions.misusing.NotAMockException:
Argument passed to verify() is of type Class and is not a mock!
Make sure you place the parenthesis correctly!
See the examples of correct verifications:
verify(mock).someMethod();
verify(mock, times(10)).someMethod();
verify(mock, atLeastOnce()).someMethod();
Run Code Online (Sandbox Code Playgroud)
将课程传递给的正确方法是什么verifyStatic?我在网上可以找到的所有示例都是针对2.xx之前的版本,其中verifyStatic没有类参数。
我正在尝试遵循https://www.tensorflow.org/tutorials/seq2seq中的tensorflow教程.
数据似乎加载正常,但是当我初始化模型时,我收到以下错误:
Traceback (most recent call last):
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/execute.py", line 334, in <module>
train()
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/execute.py", line 151, in train
model = create_model(sess, False)
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/execute.py", line 113, in create_model
forward_only=forward_only)
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/seq2seq_model_tf.py", line 181, in __init__
softmax_loss_function=softmax_loss_function)
File "/Users/<username>/anaconda/envs/tensorflow_source_gpu/lib/python2.7/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 1206, in model_with_buckets
decoder_inputs[:bucket[1]])
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/seq2seq_model_tf.py", line 180, in <lambda>
lambda x, y: seq2seq_f(x, y, False),
File "/Users/<username>/PycharmProjects/tensorflow_chatbot/seq2seq_model_tf.py", line 144, in seq2seq_f
dtype=dtype)
File "/Users/<username>/anaconda/envs/tensorflow_source_gpu/lib/python2.7/site-packages/tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.py", line 848, in embedding_attention_seq2seq
encoder_cell = copy.deepcopy(cell)
File "/Users/<username>/anaconda/envs/tensorflow_source_gpu/lib/python2.7/copy.py", line 174, in …Run Code Online (Sandbox Code Playgroud) 我有一个在Tensorflow r0.12中训练的模型,它使用创建了检查点文件SaverV2.我的模型是使用rnn_cell和rnn_cell.GRUCell来自的RNN tensorflow.python.ops.自从改为1.0后,这个软件包已根据这个答案转移到core_rnn_cell_impl了tensorflow.contrib.rnn.python.ops
我tf_update.py从这里运行文件以将我的文件更新为新版本.但是,自更新以来,我的旧检查点文件不起作用.似乎新GRUCell实现所需的某些变量不存在或具有不同的名称.
示例错误(有132个这样的错误):
2017-02-22 11:36:08.037315: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights not found in checkpoint
2017-02-22 11:36:08.037382: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights/Adam not found in checkpoint
2017-02-22 11:36:08.037494: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/biases/Adam not found in checkpoint
2017-02-22 11:36:08.037499: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights/Adam_1 not found in checkpoint
2017-02-22 11:36:08.037538: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/weights not …Run Code Online (Sandbox Code Playgroud)