【发布时间】:2021-07-10 14:25:12
【问题描述】:
我一直在使用各种类型的数据集在 Tensorflow.js 中构建一些简单的线性回归模型。但是,我现在想看看我的数据集中的日期和价格之间的关系。
在之前的模型中,我将价格或其他特征归一化,以便张量表示为 0 到 1 之间的向量。
如果第一个日期必须为 0,最后一个日期必须在 1 范围内,那么这个日期将如何处理?此外,我之后需要对张量进行非规范化。
我可以使用 date.fns 之类的库将日期转换为 unix 时间戳...但我想知道是否有更简洁的方法来做到这一点。
我的规范化和非规范化函数:
function normalise (tensor) {
const min = tensor.min();
const max = tensor.max();
const normalisedTensor = tensor.sub(min).div(max.sub(min))
return {
tensor : normalisedTensor,
min,
max
}
}
function denormalise(tensor, min, max) {
const denormalisedTensor = tensor.mul(max.sub(min)).add(min);
return denormalisedTensor
}
【问题讨论】:
-
具体日期是什么?
-
这种形式的交易日期'2021-03-21
标签: tensorflow machine-learning deep-learning linear-regression tensorflow.js