Parcourir la source

Fix neural network UI

Alexey Edelev il y a 5 ans
Parent
commit
27e5a61f3c

+ 1 - 0
gui/visualizermodel.cpp

@@ -40,6 +40,7 @@ VisualizerModel::VisualizerModel(std::shared_ptr<RemoteControlClient> &client, Q
 {
     qRegisterProtobufType<remotecontrol::LayerMatrix>();
     qRegisterProtobufType<remotecontrol::NetworkState>();
+    qRegisterProtobufType<remotecontrol::Matrix>();
 
     m_client->getConfiguration({}, this, [this](QGrpcAsyncReply *reply) {
         qDeleteAll(m_layers);

+ 7 - 6
neuralnetwork/remotecontrol/remotecontrol.go

@@ -54,13 +54,18 @@ type RemoteControl struct {
 	config           *Configuration
 }
 
-func (rw *RemoteControl) Init(nn *neuralnetwork.NeuralNetwork) {
-	rw.nn = nn
+func NewRemoteControl() (rw *RemoteControl) {
+	rw = &RemoteControl{}
 	rw.activationsQueue = make(chan *LayerMatrix, 5)
 	rw.biasesQueue = make(chan *LayerMatrix, 5)
 	rw.weightsQueue = make(chan *LayerMatrix, 5)
 	rw.stateQueue = make(chan int, 2)
 	rw.config = &Configuration{}
+	return
+}
+
+func (rw *RemoteControl) Init(nn *neuralnetwork.NeuralNetwork) {
+	rw.nn = nn
 	for _, size := range rw.nn.Sizes {
 		rw.config.Sizes = append(rw.config.Sizes, int32(size))
 	}
@@ -127,7 +132,6 @@ func (rw *RemoteControl) Activations(_ *None, srv RemoteControl_ActivationsServe
 		default:
 		}
 		msg := <-rw.activationsQueue
-		fmt.Println("Send Activations")
 		srv.Send(msg)
 	}
 }
@@ -141,7 +145,6 @@ func (rw *RemoteControl) Biases(_ *None, srv RemoteControl_BiasesServer) error {
 		default:
 		}
 		msg := <-rw.biasesQueue
-		fmt.Println("Send Biases")
 		srv.Send(msg)
 	}
 }
@@ -155,7 +158,6 @@ func (rw *RemoteControl) Weights(_ *None, srv RemoteControl_WeightsServer) error
 		default:
 		}
 		msg := <-rw.weightsQueue
-		fmt.Println("Send Weights")
 		srv.Send(msg)
 	}
 }
@@ -172,7 +174,6 @@ func (rw *RemoteControl) State(_ *None, srv RemoteControl_StateServer) error {
 		msg := &NetworkState{
 			State: NetworkState_State(state),
 		}
-		fmt.Printf("Send state %v %v\n", msg, state)
 		srv.Send(msg)
 	}
 }

+ 1 - 1
neuralnetwork/snakesimulator/snakesimulator.go

@@ -58,7 +58,7 @@ func NewSnakeSimulator(maxVerificationSteps int) (s *SnakeSimulator) {
 		statsUpdateQueue:     make(chan bool, 2),
 		speedQueue:           make(chan uint32, 1),
 		speed:                10,
-		remoteControl:        &remotecontrol.RemoteControl{},
+		remoteControl:        remotecontrol.NewRemoteControl(),
 	}
 	return
 }