我正在研究多标签问题,我正在尝试确定模型的准确性.
我的模特:
NUM_CLASSES = 361
x = tf.placeholder(tf.float32, [None, IMAGE_PIXELS])
y_ = tf.placeholder(tf.float32, [None, NUM_CLASSES])
# create the network
pred = conv_net( x )
# loss
cost = tf.reduce_mean( tf.nn.sigmoid_cross_entropy_with_logits( pred, y_) )
# train step
train_step = tf.train.AdamOptimizer().minimize( cost )
Run Code Online (Sandbox Code Playgroud)
我想以两种不同的方式计算准确度
- 正确预测的所有标签的百分比 - 正确预测所有标签的图像的百分比
不幸的是,我只能计算出正确预测的所有标签的百分比.
我认为这段代码会计算正确预测所有标签的图像百分比
correct_prediction = tf.equal( tf.round( pred ), tf.round( y_ ) )
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
Run Code Online (Sandbox Code Playgroud)
并且这个代码是正确预测的所有标签的百分比
pred_reshape = tf.reshape( pred, [ BATCH_SIZE * NUM_CLASSES, 1 ] )
y_reshape = tf.reshape( y_, [ BATCH_SIZE …Run Code Online (Sandbox Code Playgroud) 我正在开发一款Android应用,它将识别GO板并为其创建SGF文件。
我制作了一个能够检测木板并扭曲透视图使其变为正方形的版本(下面的代码和示例图片),不幸的是,添加石头时它变得更难一点。(下面的图片)
关于普通棋盘游戏的重要事项:
如果我错了,请纠正我,但我认为我目前的方法不是一个好方法。是否有人对我如何将石头和线条与图片的其余部分区分开来有一个大致的了解?
我的代码:
Mat input = inputFrame.rgba(); //original image
Mat gray = new Mat(); //grayscale image
//convert image to grayscale
Imgproc.cvtColor( input, gray, Imgproc.COLOR_RGB2GRAY);
//try to improve histogram (more contrast)
equalizeHist(gray, gray);
//blur image
Size s = new Size(5,5);
GaussianBlur(gray, gray, s, 0);
//apply adaptive treshold
adaptiveThreshold( gray, gray, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY,11,2);
//adding secondary treshold, removes a lot of noise
threshold(gray, gray, 0, 255, Imgproc.THRESH_BINARY + Imgproc.THRESH_OTSU);
Run Code Online (Sandbox Code Playgroud)
一些图像:

(来源:八十二.axc.nl …
我正在从convnetjs切换到tensorflow,并且正在努力获得读取图像和训练带有张量流的cnn的基础知识.
我在两个文件夹中有一堆160*120*1的图像:火车/去火车/没有所以我使用两个班级.
不知何故,我可以了解一下tf.train.slice_input_producer与sess.run(train_step.
我的代码:
import tensorflow as tf
def read_my_list( minId, maxId ):
""" create list with train/no and train/go from 1 to maxid
max maxId = 50000
"""
filenames = []
labels = []
for num in range( minId, maxId ):
filenames.append( "/media/boss/tensor/train/go/" + str( num ) + ".jpg" )
labels.append( int( 1 ) )
filenames.append( "/media/boss/tensor/train/no/" + no_go_name( num ) + ".jpg" )
labels.append( int( 0 ) )
# return list with all filenames
return filenames, labels
def …Run Code Online (Sandbox Code Playgroud)