激活功能获取星期几 [英] Activation function to get day of week

查看:118
本文介绍了激活功能获取星期几的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序来预测什么时候会发生。我不知道星期几(1-7)会获得哪个激活功能。

I'm writing a program to predict when will something happens. I don't know which activation function to get output in day of week (1-7).

我尝试了S型函数,但是我需要输入预测的日期并输出它的概率,我不希望这样。

I tried sigmoid function but i need to input the predicted day and it output probability of it, I don't want it to be this way.

我希望激活函数将0返回到无穷大,ReLU是此任务的最佳激活函数吗?

I expect the activation function returning 0 to infinite, is ReLU the best activation function for this task?

编辑:

此外,如果我想输出7天以上的时间,例如,x将在今天的第9天或今天的第15天出现阴影,依此类推?我正在寻找实现此目的的动态方法

also, what if i wanted output more than 7 days, for example, x will hapen in 9th day from today, or 15th day from today, etc? I'm looking for dynamic ways to do this

推荐答案

我想添加到@venkata krishnan的观点上,这引起了问题设置中的有效点。您会在下面找到对原始问题的答案,但我强烈建议您先阅读以下评论。

I want to add onto the point of @venkata krishnan, which raises a valid point in your problem setting. You will find an answer to your original question further down, but I strongly suggeste you read the following comment first.

通常,您希望区分类别,序数和区间变量。我在中给出了相对较长的解释对于Stackoverflow 有一个不同的答案,这可能有助于更详细地了解此概念。

在您的情况下,您最想了解自己是 怎么错。当然,假设您在做什么并将其解释为区间变量是完全合理的,因此在不同值之间具有假定的顺序(和距离)。

是什么有问题的是,您假设离散变量上的连续空间。例如,解释 4.3 的输出没有任何意义,因为您只能区分 4 (星期五) (假设您从0开始对天进行编号)或 5 (星期六)。介于两者之间的任何值都必须四舍五入,这非常好-直到您要对此损失执行反向传播。
这是有问题的,因为无论您如何舍入值,本质上都是在引入非凸且非连续的函数。再次举例说明,您可以假设四舍五入到最接近的数字。然后,当值为 4.5 时,您会发现损失突然增加,这是无差别的,因此会给优化器带来困难,可能会限制系统收敛。

Generally, you want to discern between categorical, ordinal and interval variables. I have given a relatively lengthy explanation in a different answer on Stackoverflow, it might be helpful to understand this concept in more detail.
In your scenario, you mostly want to have an understanding of "how wrong" you are. Of course, it is perfectly reasonable to assume what you are doing and interpret it as a interval variable, and therefore have an assumed ordering (and a distance) between different values.
What is problematic, though, is the fact that you are assuming a continuous space on a discrete variable. E.g., it does not make any sense to interpret the output of 4.3, since you can only tell between 4 (Friday, assuming you start numbering your days at 0), or 5 (Saturday). Any value in between would have to be rounded, which is perfectly fine - until you want to perform backpropagation on this loss. It is problematic, because you are essentially introducing a non-convex and non-continous function, no matter how you "round" your values. Again, to exemplify this, you could assume to round to the nearest number; then, at the value of 4.5, you would see a sudden increase in the loss, which is non-differentialbe, and will therefore put a hard time on your optimizer, potentially limiting convergence of your system.

相反,如果您利用@venkata krishnan的建议使用多个输出神经元,则可能会丢失距离信息(多少天了关闭),但您当然仍然可以按照自己喜欢的任何方式解释您的损失。对于离散值变量,这当然是更好的选择。

If, instead, you utilize several output neurons, as suggested by @venkata krishnan, you might lose the information of distance (how many days you are off) on paper, but you can of course still interpret your loss in any way you like. This would certainly be the better option for a discrete-valued variable.

要回答您的原始问题:我个人将确保您的损失函数的上限和下限都是有限的,否则您可能会有不确定的/不一致的损失值,这可能会导致低于标准的优化。一种方法是重新缩放Sigmoid函数( sigmoid(R)的共域是 [0,1] 。最终,您可以将输出乘以 6 ,得到的值范围是 [0,6] ,并且可以(四舍五入后)覆盖所需的所有值。

To answer your original question: I personally would make sure that your loss function is bounded both in the upper and lower level, as you could otherwise have undefined/inconsistent loss values, that might lead to subpar optimization. One way to do this is to re-scale a Sigmoid function (the co-domain of sigmoid(R) is [0,1]. Eventually, you can then just multiply your output by 6, to get a value range that is [0,6], and could (after rounding) cover all the values you want.

这篇关于激活功能获取星期几的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆