小编Dav*_*ein的帖子

比较两个对象时,JUnit assertEquals()不起作用

我正试图掌握Java.单元测试对我来说非常重要,所以最近我开始使用JUnit.这很难开始,但我已经掌握了它.除了比较同一个类的两个对象(我没有尝试测试创建不同类的对象的函数)之外,我的所有测试都达到了这一点.基本上,当我在一个类中创建一个类的新实例的方法时,我尝试测试该方法,我得到一个奇怪的错误.

"预计:runnersLog.MTLog@433c675d但是runnersLog.MTLog@3f91beef"

我试过研究这个问题,但没有找到任何帮助.这是我在github上的类的链接.我试图测试的mt()方法是方法,测试类是ILogTest.

这不是我遇到这个问题的唯一情况.对于任何具有返回同一类的新对象的方法的类,我得到的是完全相同的3f91beef错误(即使对象更复杂 - 带参数)

java testing methods junit unit-testing

5
推荐指数
1
解决办法
1万
查看次数

TensorFlow FileWriter没有写入文件

我正在训练一个简单的TensorFlow模型.训练方面工作正常,但没有写入日志/tmp/tensorflow_logs,我不知道为什么.有人能提供一些见解吗?谢谢

# import MNIST
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

import tensorflow as tf

# set parameters
learning_rate = 0.01
training_iteration = 30
batch_size = 100
display_step = 2

# TF graph input
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])

# create a model

# set model weights
# 784 is the dimension of a flattened MNIST image
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))

with tf.name_scope("Wx_b") as scope:
    # construct linear model …
Run Code Online (Sandbox Code Playgroud)

python logging filewriter tensorflow

5
推荐指数
1
解决办法
5073
查看次数