示例#1
0
/*!\brief Overwrite one network with another.
 * \param dest Pointer to a neural network.
 * \param src Pointer to a neural network.
 *
 * The neural network dest becomes a copy of the neural network src.
 * Note that dest must be an allocated neural network and its original
 * contents is discarded (with net_free()).
 */
void
net_overwrite (network_t *dest, const network_t *src)
{
  network_t *new_net, *tmp_net;

  assert (dest != NULL);
  assert (src != NULL);

  new_net = net_copy (src);

  /* switch new_net and dest, so it is possible to keep the same pointer */
  tmp_net = malloc (sizeof (network_t));
  memcpy (tmp_net, new_net, sizeof (network_t));
  memcpy (new_net, dest, sizeof (network_t));
  memcpy (dest, tmp_net, sizeof (network_t));
  free (tmp_net);

  net_free (new_net);
}
示例#2
0
void FannTest::AssertCreateAndCopy(unsigned int numLayers, unsigned int *layers, unsigned int neurons,
                                   unsigned int connections) {
    AssertCreate(net, numLayers, layers, neurons, connections);
    FANN::neural_net net_copy(net);
    AssertCreate(net_copy, numLayers, layers, neurons, connections);
}