Exemplo n.º 1
0
// Serialize serializes the block.
func (n *NetworkBlock) Serialize() ([]byte, error) {
	initData, err := json.Marshal(n.batcherBlock.Start)
	if err != nil {
		return nil, err
	}
	serializers := []serializer.Serializer{
		serializer.Int(n.batcherBlock.StateSize),
		n.network,
		serializer.Bytes(initData),
	}
	return serializer.SerializeSlice(serializers)
}
Exemplo n.º 2
0
// Serialize serializes the block.
func (g *GRU) Serialize() ([]byte, error) {
	initData, err := json.Marshal(g.initState)
	if err != nil {
		return nil, err
	}
	slist := []serializer.Serializer{
		serializer.Int(g.hiddenSize),
		g.inputValue,
		g.resetGate,
		g.updateGate,
		serializer.Bytes(initData),
	}
	return serializer.SerializeSlice(slist)
}
Exemplo n.º 3
0
// Serialize serializes the LSTM.
func (l *LSTM) Serialize() ([]byte, error) {
	initData, err := json.Marshal(l.initState)
	if err != nil {
		return nil, err
	}
	slist := []serializer.Serializer{
		serializer.Int(l.hiddenSize),
		l.inputValue,
		l.inputGate,
		l.rememberGate,
		l.outputGate,
		serializer.Bytes(initData),
	}
	return serializer.SerializeSlice(slist)
}