|
@@ -38,23 +38,57 @@ VisualizerModel::VisualizerModel(std::shared_ptr<RemoteControlClient> &client, Q
|
|
|
, m_client(client)
|
|
|
{
|
|
|
m_client->getConfiguration({}, this, [this](QGrpcAsyncReply *reply) {
|
|
|
+ qDeleteAll(m_layers);
|
|
|
m_networkConfig = reply->read<Configuration>();
|
|
|
+ for(int i = 0; i < m_networkConfig.sizes().size(); i++) {
|
|
|
+ m_layers.append(new NetworkLayerState);
|
|
|
+ m_layers.last()->m_activations.setDimentions(m_networkConfig.sizes()[i], 1);
|
|
|
+ QList<ValueIndicator*> data;
|
|
|
+ for (int k = 0; k < m_networkConfig.sizes()[i]; k++) {
|
|
|
+ data.append(new ValueIndicator);
|
|
|
+ }
|
|
|
+ m_layers.last()->m_activations.setData(data);
|
|
|
+ }
|
|
|
sizesChanged();
|
|
|
});
|
|
|
|
|
|
- QObject::connect(client.get(), &remotecontrol::RemoteControlClient::ActivationsUpdated, [](const remotecontrol::LayerMatrix &activations) {
|
|
|
+ QObject::connect(client.get(), &remotecontrol::RemoteControlClient::ActivationsUpdated, [this](const remotecontrol::LayerMatrix &activations) {
|
|
|
+ if (m_layers.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Dense dense(activations.matrix().matrix());
|
|
|
- qDebug() << "ActivationsUpdated:" << dense.rows() << dense.columns();
|
|
|
+ m_layers[activations.layer()]->m_activations.updateValues(Dense(activations.matrix().matrix()));
|
|
|
+// qDebug() << "ActivationsUpdated:" << dense.rows() << dense.columns() << activations.layer();
|
|
|
});
|
|
|
- QObject::connect(client.get(), &remotecontrol::RemoteControlClient::BiasesUpdated, [](const remotecontrol::LayerMatrix &biases) {
|
|
|
+ QObject::connect(client.get(), &remotecontrol::RemoteControlClient::BiasesUpdated, [this](const remotecontrol::LayerMatrix &biases) {
|
|
|
+ if (m_layers.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Dense dense(biases.matrix().matrix());
|
|
|
- qDebug() << "BiasesUpdated:" << dense.rows() << dense.columns();
|
|
|
+// qDebug() << "BiasesUpdated:" << dense.rows() << dense.columns();
|
|
|
});
|
|
|
- QObject::connect(client.get(), &remotecontrol::RemoteControlClient::WeightsUpdated, [](const remotecontrol::LayerMatrix &weights) {
|
|
|
+ QObject::connect(client.get(), &remotecontrol::RemoteControlClient::WeightsUpdated, [this](const remotecontrol::LayerMatrix &weights) {
|
|
|
+ if (m_layers.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Dense dense(weights.matrix().matrix());
|
|
|
- qDebug() << "WeightsUpdated:" << dense.rows() << dense.columns();
|
|
|
+// qDebug() << "WeightsUpdated:" << dense.rows() << dense.columns();
|
|
|
});
|
|
|
client->subscribeActivationsUpdates({});
|
|
|
client->subscribeBiasesUpdates({});
|
|
|
client->subscribeWeightsUpdates({});
|
|
|
}
|
|
|
+
|
|
|
+ValueIndicator *VisualizerModel::activation(int layer, int row)
|
|
|
+{
|
|
|
+ ValueIndicator* indicator = m_layers[layer]->m_activations.value<ValueIndicator*>(row, 0);
|
|
|
+ QQmlEngine::setObjectOwnership(indicator, QQmlEngine::CppOwnership);
|
|
|
+ return indicator;
|
|
|
+}
|
|
|
+
|
|
|
+ValueIndicator *VisualizerModel::weight(int layer, int row, int column)
|
|
|
+{
|
|
|
+ ValueIndicator* indicator = m_layers[layer]->m_weights.value<ValueIndicator*>(row, column);
|
|
|
+ QQmlEngine::setObjectOwnership(indicator, QQmlEngine::CppOwnership);
|
|
|
+ return indicator;
|
|
|
+}
|