略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: fann_merge_train_data

2024-11-15

fann_merge_train_data

(PECL fann >= 1.0.0)

fann_merge_train_data合并训练数据。

说明

fann_merge_train_data(resource $data1, resource $data2): resource

将 data1 和 data2 数据集合并为新的训练数据 resource.

参数

data1

神经网络训练数据 资源

data2

神经网络训练数据 资源

返回值

成功,则返回合并的训练数据 resource, 错误则返回 false .

add a noteadd a note

User Contributed Notes 1 note

up
2
geekgirljoy at gmail dot com
3 years ago
There will be times when you need to merge separate data sets into a new single set.

This code demonstrates how to merge the XOR dataset from two separate files into a single training file.

File (xor_part_1.data):
1 2 1
-1 -1
-1

File (xor_part_2.data):
3 2 1
-1 1
1
1 -1
1
1 1
-1

Resulting File (xor_complete.data):
4 2 1
-1 -1
-1
-1 1
1
1 -1
1
1 1
-1

<?php
// Create partial data resources
$train_data_1 = fann_read_train_from_file("xor_part_1.data");
$train_data_2 = fann_read_train_from_file("xor_part_2.data");

// Merge into new data resource
$train_data = fann_merge_train_data ($train_data_1, $train_data_2);

// Remove the partial data resources from memory
fann_destroy_train ( $train_data_1 );
fann_destroy_train ( $train_data_2 );

// Save the new complete Data file
fann_save_train ( $train_data , "xor_complete.data");

// Remove the complete data resources from memory
fann_destroy_train ( $train_data );

echo
'All Done!' . PHP_EOL;
?>

官方地址:https://www.php.net/manual/en/function.fann-merge-train-data.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3