我可能会遗漏一些东西,但是我找不到任何connect()将组件定义为类(扩展React.Component)的示例 ,它总是包装定义为简单函数的组件.
像这样的电话:
connect(mapStateToProps, mapDispatchToProps)(HomeView)
Run Code Online (Sandbox Code Playgroud)
在哪里HomeView extends React.Component,我收到一个Cannot call a class as a function错误.
任何帮助将非常感激.
编辑(对不起代码,我不知道可能是什么相关):
路线/主页/分量/ HomeView.js
import React from 'react'
import './HomeView.scss'
class HomeView extends React.Component {
render() {
return (
<div>
<h4>Home</h4>
<div id="g-signin2" data-onsuccess={this.props.signin} />
</div>
)
}
componentDidMount() {
gapi.signin2.render('g-signin2', {
'scope': 'profile email',
'width': 200,
'height': 50,
'longtitle': true,
'theme': 'dark'
});
}
}
HomeView.propTypes = {
signin : React.PropTypes.func.isRequired
}
export default HomeView
Run Code Online (Sandbox Code Playgroud)
路线/主页/模块/ home.js …
我无法在TypeScript中使用前面提到的组合这个例子.
我有<script src="lib/three.min.js"></script>和<script src="lib/OrbitControls.js"></script>我的html <head>和typescript文件<body>:
/// <reference path="lib\three.d.ts" />
...
this.controls = new THREE.OrbitControls(this.camera); //there's the error
this.controls.addEventListener('change', this.render);
...
Run Code Online (Sandbox Code Playgroud)
和
this.controls.update();
Run Code Online (Sandbox Code Playgroud)
在周期性调用render()函数.据我所知,设置与expample相同,但在编译OrbitControls构造函数行时给出了一个巨大的错误(缩写):
The property 'OrbitControls' does not exist on value of type '{REVISION:string;
CullFace: {[x: number ...
Run Code Online (Sandbox Code Playgroud)
我猜这个错误中有整个Threejs,因为Visual Studio在我点击它时崩溃了:).谢谢你的帮助.
我有一个时间序列数据集,我正在尝试训练一个网络,以便它过度拟合(显然,这只是第一步,我将与过度拟合作斗争).
网络有两层:LSTM(32个神经元)和密集(1个神经元,没有激活)
培训/模型有这些参数:
epochs: 20,steps_per_epoch: 100,loss: "mse",optimizer: "rmsprop".
TimeseriesGenerator产生输入系列:length: 1,sampling_rate: 1,batch_size: 1.
我希望网络能够记住这么小的数据集(我尝试过更复杂的网络无济于事),训练数据集的损失几乎为零.它不是,当我在训练集上可视化结果时,如下所示:
y_pred = model.predict_generator(gen)
plot_points = 40
epochs = range(1, plot_points + 1)
pred_points = numpy.resize(y_pred[:plot_points], (plot_points,))
target_points = gen.targets[:plot_points]
plt.plot(epochs, pred_points, 'b', label='Predictions')
plt.plot(epochs, target_points, 'r', label='Targets')
plt.legend()
plt.show()
Run Code Online (Sandbox Code Playgroud)
我明白了:
预测的幅度稍微小一些,但与目标正好相反.顺便说一句.这是没有记忆的,即使对于算法没有训练过的测试数据集,它们也是反转的.似乎我的网络不是记住数据集而是学会否定输入值并稍微缩小它.知道为什么会这样吗?它似乎不是优化器应该收敛的解决方案(损失相当大).
编辑(我的代码的一些相关部分):
train_gen = keras.preprocessing.sequence.TimeseriesGenerator(
x,
y,
length=1,
sampling_rate=1,
batch_size=1,
shuffle=False
)
model = Sequential() …Run Code Online (Sandbox Code Playgroud) 交集对象(由 返回raycaster.intersectObject())具有face和faceIndex属性。但是,如果相交对象是 ,则这些属性为 null BufferGeometry。另一方面,该point物业按预期运作。
有什么方法可以确定哪一面被BufferGeometry击中?显然没有faces数组,BufferGeometry但了解(例如)position定义击中面的属性中的点索引会有很大帮助。
(我当然可以使用一些数学,因为我知道所有点的坐标,但这会影响我在大型几何体上的表现)
javascript ×2
three.js ×2
html ×1
keras ×1
python ×1
react-redux ×1
reactjs ×1
tensorflow ×1
typescript ×1