我是 ML 的新手,我正在学习本教程,该教程教授如何基于某些期货进行加密货币预测。
我做预测的代码:
model = load_model("Path//myModel.model")
ready_x = preprocess_df(main_df) # the function returns array of price sequences and targets (0-buy,1-sells): return np.array(X), y
predictions = []
for x in ready_x:
l_p = model.predict_classes(x) #error occurs on this line
predictions.append(l_p[0])
plot_prediction(main_df, predictions)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
ValueError:检查输入时出错:预期 lstm_input 有 3 个维度,但得到了形状为 (69188, 1) 的数组
我真的不明白这个错误的想法,这实际上是我在著名的猫狗分类之后的第二个 ML 项目。所以没有太多调试经验,我确实先学习了理论,关于神经元和它们之间的关系,但仍然很难将这些知识应用到实际项目中。所以这个项目的想法是根据过去 60 分钟的价格(经过训练)预测未来 3 分钟的未来价格。
该模型如下所示:
model = Sequential()
model.add(LSTM(128, input_shape=(train_x.shape[1:]),return_sequences=True))
model.add(Dropout(0.2))
model.add(BatchNormalization())
model.add(LSTM(128, return_sequences=True))
model.add(Dropout(0.1))
model.add(BatchNormalization())
model.add(LSTM(128))
model.add(Dropout(0.2))
model.add(BatchNormalization())
model.add(Dense(32, …Run Code Online (Sandbox Code Playgroud) 我有一个简单的应用程序,显示当地酒店的列表。每个列表项都有一个<Link/>重定向到另一个组件的组件,该组件在地图上显示该特定酒店的位置。当切换路由时,组件似乎<ProductList/>被破坏了,其中的所有状态也被破坏了。所以每次当它进行新的 API 调用并重新渲染时。我尝试将其保存在本地存储中componentWillUnmount并检索它,useEffect()以便我可以有条件地进行 API 调用,它可以工作,但有时不起作用。
import React, { useState, useEffect} from "react";
import ProductItem from "../Components/ProductItem";
import axios from "axios";
const ProductList = () => {
const [hotelList, setHotelList] = useState([]);
// Get user location by IP
const getCurrentLocation = () => {
return fetch("https://ipinfo.io/json?token=MyToken").then(
(response) => response.json()
);
};
// Get list of hotels in specific location
const getHotelsInLocation = (destInfo) => {
console.log('destInfo is: ', destInfo)
const options = { …Run Code Online (Sandbox Code Playgroud) 我们知道strcat()修饰了指向目标数组的指针,并将其与源字符串连接起来。目标数组应足够大以存储串联的结果。最近我发现,即使目标数组的大小不足以添加第二个字符串,对于小型程序,strcat()仍然可以按预期执行。我开始浏览stackoverflow并发现了几个 - 这个问题的答案。我想更深入地了解在下面运行此代码时硬件层中到底发生了什么?
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
char p[6] = "Hello";
cout << "Length of p before = " << strlen(p) << endl;
cout << "Size of p before = " << sizeof(p) << endl;
char as[8] = "_World!";
cout << "Length of as before = " << strlen(as) << endl;
cout << "Size of as before = " << sizeof(as) << endl;
cout << strcat(p,as) << endl;
cout << …Run Code Online (Sandbox Code Playgroud) 假设我有一个数组
int x[5] = {1,2,3,4,5};
Run Code Online (Sandbox Code Playgroud)
和功能
int at(int p[],const int i){
return p[i];
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试访问诸如
cout << at(x,4);//works fine,output is 5
cin >> at(x,3);// error
Run Code Online (Sandbox Code Playgroud)
我知道它仅返回该索引的常量,并且我们无法更改常量。因此,有某种方法可以修改此函数以获取对数组元素的完全访问权限,从而能够更改指定索引上的值。