略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: fann_subset_train_data

2024-11-15

fann_subset_train_data

(PECL fann >= 1.0.0)

fann_subset_train_data返回一个训练数据子集的副本。

说明

fann_subset_train_data(resource $data, int $pos, int $length): resource

返回一个训练数据子集的副本 resource, 从 pos 位置开始向前步进 length 个元素。

fann_subset_train_data(train_data, 0, fann_length_train_data(train_data))fann_duplicate_train_data()函数的效果是一样的。

参数

data

神经网络训练数据 资源

pos

起始位置。

length

复制元素的数量。

返回值

成功时返回训练数据 资源,发生错误返回 false

参见

add a noteadd a note

User Contributed Notes 1 note

up
0
geekgirl dot joy at gmail dot com
2 years ago
<?php
// Use this code to split your data into smaller sets.
// Useful for splitting your training data into training and testing groups

// Load Data
$data_file = "MyTrainingData.data";
$train_data = fann_read_train_from_file(dirname(__FILE__)  .  DIRECTORY_SEPARATOR  $data_file);

// Calculate how many examples are in the first group
$total_length = fann_length_train_data($train_data);
$a_length = floor($total_length / 10);

// Split the subsets
$training_data_a  = fann_subset_train_data($train_data, 0, $a_length);
$training_data_b  = fann_subset_train_data($train_data, $a_length, $total_length-$a_length);

// Save the training data to separate files
fann_save_train ($training_data_a, 'MyTrainingData_Subset_A.data'); // 1/10 of the training data
fann_save_train ($training_data_b, 'MyTrainingData_Subset_B.data'); // 9/10 of the training data

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

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