在Tensorflow上输出回归的CNN图像识别 [英] CNN Image Recognition with Regression Output on Tensorflow
问题描述
我想基于使用CNN的图像预测估计的等待时间。因此,我想这将使用CNN来输出使用RMSE的损失函数的回归类型输出,这是我现在正在使用的函数,但是它无法正常工作。
I want to predict the estimated wait time based on images using a CNN. So I would imagine that this would use a CNN to output a regression type output using a loss function of RMSE which is what I am using right now, but it is not working properly.
有人可以指出使用CNN图像识别来输出类似于等待时间的标量/回归输出(而不是类输出)的示例,以便我可以使用他们的技术使它起作用,因为我无法来找到合适的示例。
Can someone point out examples that use CNN image recognition to output a scalar/regression output (instead of a class output) similar to wait time so that I can use their techniques to get this to work because I haven't been able to find a suitable example.
我发现的所有CNN示例都是针对MSINT数据的,并区分了猫和狗,它们输出的是类输出,而不是数字/等待时间的标量输出。
All of the CNN examples that I found are for the MSINT data and distinguishing between cats and dogs which output a class output, not a number/scalar output of wait time.
有人可以给我一个使用CNN张量流的示例,它基于图像识别给出标量或回归输出。
Can someone give me an example using tensorflow of a CNN giving a scalar or regression output based on image recognition.
非常感谢!老实说,我非常执着,没有任何进展,已经花了两个多星期来解决这个相同的问题。
Thanks so much! I am honestly super stuck and am getting no progress and it has been over two weeks working on this same problem.
推荐答案
Udacity自动驾驶汽车模型会从行车记录仪获取输入图像,并预测要保持在道路上的转向角(即连续标量)...通常在汽车顶部一个或多个完全连接的层之后使用回归输出CNN层。
Check out the Udacity self-driving-car models which take an input image from a dash cam and predict a steering angle (i.e. continuous scalar) to stay on the road...usually using a regression output after one or more fully connected layers on top of the CNN layers.
https://github.com/udacity/self-driving-car/tree/master/steering-models/community-models
这是典型的模型:
https://github.com/udacity/self-driving-car/tree/master/steering-models/community-models/autumn
...它使用 tf.atan()
或您可以使用 tf.tanh()
或只是线性获取最终输出 y
。
...it uses tf.atan()
or you can use tf.tanh()
or just linear to get your final output y
.
使用MSE进行亏损功能。
Use MSE for your loss function.
这里是喀拉拉邦的另一个示例 ...
model = models.Sequential()
model.add(convolutional.Convolution2D(16, 3, 3, input_shape=(32, 128, 3), activation='relu'))
model.add(pooling.MaxPooling2D(pool_size=(2, 2)))
model.add(convolutional.Convolution2D(32, 3, 3, activation='relu'))
model.add(pooling.MaxPooling2D(pool_size=(2, 2)))
model.add(convolutional.Convolution2D(64, 3, 3, activation='relu'))
model.add(pooling.MaxPooling2D(pool_size=(2, 2)))
model.add(core.Flatten())
model.add(core.Dense(500, activation='relu'))
model.add(core.Dropout(.5))
model.add(core.Dense(100, activation='relu'))
model.add(core.Dropout(.25))
model.add(core.Dense(20, activation='relu'))
model.add(core.Dense(1))
model.compile(optimizer=optimizers.Adam(lr=1e-04), loss='mean_squared_error')
它们与MNIST示例的主要区别在于,与其将logits的N维矢量漏斗化为softmax w /交叉熵损失,不如将其降至1维矢量w / MSE亏损。
They key difference from the MNIST examples is that instead of funneling down to a N-dim vector of logits into softmax w/ cross entropy loss take it down to a 1-dim vector w/ MSE loss.
这篇关于在Tensorflow上输出回归的CNN图像识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!