⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fann_cpp_subclass.h

📁 python 神经网络 数据挖掘 python实现的神经网络算法
💻 H
📖 第 1 页 / 共 2 页
字号:
            return neural_net::create_shortcut_array( layers->array_len, layers->array);
        }

        /* Method: run

	        Will run input through the neural network, returning an array of outputs, the number of which being 
	        equal to the number of neurons in the output layer.

	        See also:
		        <test>, <fann_run>

	        This function appears in FANN >= 1.0.0.
        */ 

         helper_array<fann_type>* run(helper_array<fann_type> *input)
         {
            if (ann == NULL && input->array_len!=ann->num_input)
            {
                return NULL;
            }
            helper_array<fann_type>* res= new helper_array<fann_type>;
            res->array=fann_run(ann, input->array);
            res->array_len=ann->num_output;
            res->can_delete=false;
            return res;
         }



#ifndef FIXEDFANN
        /* Method: train

           Train one iteration with a set of inputs, and a set of desired outputs.
           This training is always incremental training (see <FANN::training_algorithm_enum>),
           since only one pattern is presented.
           
           Parameters:
   	        ann - The neural network structure
   	        input - an array of inputs. This array must be exactly <fann_get_num_input> long.
   	        desired_output - an array of desired outputs. This array must be exactly <fann_get_num_output> long.
           	
   	        See also:
   		        <train_on_data>, <train_epoch>, <fann_train>
           	
   	        This function appears in FANN >= 1.0.0.
         */

        void train(helper_array<fann_type> *input, helper_array<fann_type> *desired_output)
        {
            if (ann != NULL && input->array_len==ann->num_input && desired_output->array_len==ann->num_output)
            {
                fann_train(ann, input->array, desired_output->array);
            }
        }

#endif /* NOT FIXEDFANN */

        /* Method: test

           Test with a set of inputs, and a set of desired outputs.
           This operation updates the mean square error, but does not
           change the network in any way.
           
           See also:
   		        <test_data>, <train>, <fann_test>
           
           This function appears in FANN >= 1.0.0.
        */ 

         helper_array<fann_type>* test(helper_array<fann_type> *input, helper_array<fann_type>* desired_output)
         {
            if (ann == NULL)
            {
                return NULL;
            }
            helper_array<fann_type>* res= new helper_array<fann_type>;
            res->array=fann_test(ann, input->array, desired_output->array);
            res->array_len=ann->num_output;
            res->can_delete=false;
            return res;
        }


        /*************************************************************************************************************/


        /* Method: get_layer_array

            Get the number of neurons in each layer in the network.

            Bias is not included so the layers match the create methods.

            The layers array must be preallocated to at least
            sizeof(unsigned int) * get_num_layers() long.

            See also:
                <fann_get_layer_array>

           This function appears in FANN >= 2.1.0
        */

        void get_layer_array(helper_array<unsigned int>* ARGOUT)
        {
            if (ann != NULL)
            {
                ARGOUT->array_len = fann_get_num_layers(ann);
                ARGOUT->array = (unsigned int*) malloc(sizeof(unsigned int)* 
                        ARGOUT->array_len);
                fann_get_layer_array(ann, ARGOUT->array);
            }
        }

        /* Method: get_bias_array

            Get the number of bias in each layer in the network.

            The bias array must be preallocated to at least
            sizeof(unsigned int) * get_num_layers() long.

            See also:
                <fann_get_bias_array>

            This function appears in FANN >= 2.1.0
        */
        void get_bias_array(helper_array<unsigned int>* ARGOUT)
        {
            if (ann != NULL)
            {
                ARGOUT->array_len = fann_get_num_layers(ann);
                ARGOUT->array = (unsigned int*) malloc(sizeof(unsigned int)* 
                        ARGOUT->array_len);
                fann_get_bias_array(ann, ARGOUT->array);
            }
        }

        /* Method: get_connection_array

            Get the connections in the network.

            The connections array must be preallocated to at least
            sizeof(struct fann_connection) * get_total_connections() long.

            See also:
                <fann_get_connection_array>

           This function appears in FANN >= 2.1.0
        */
	
        void get_connection_array(helper_array<connection> *ARGOUT)
        {
            if (ann != NULL)
            {
                ARGOUT->array_len = fann_get_total_connections(ann); 
                ARGOUT->array = (connection*) malloc(sizeof(connection)* 
                        ARGOUT->array_len);
                fann_get_connection_array(ann, ARGOUT->array);
            }
        }
        /* Method: set_weight_array

            Set connections in the network.

            Only the weights can be changed, connections and weights are ignored
            if they do not already exist in the network.

            The array must have sizeof(struct fann_connection) * num_connections size.

            See also:
                <fann_set_weight_array>

           This function appears in FANN >= 2.1.0
        */
        void set_weight_array(helper_array<connection> *connections)
        {
            if (ann != NULL)
            {
                fann_set_weight_array(ann, connections->array, connections->array_len);
            }
        }

        /*********************************************************************/

#ifdef TODO
        /* Method: get_cascade_activation_functions

           The cascade activation functions array is an array of the different activation functions used by
           the candidates. 
           
           See <get_cascade_num_candidates> for a description of which candidate neurons will be 
           generated by this array.
           
           See also:
   		        <get_cascade_activation_functions_count>, <set_cascade_activation_functions>,
   		        <FANN::activation_function_enum>

	        This function appears in FANN >= 2.0.0.
         */
        activation_function_enum * get_cascade_activation_functions()
        {
            enum fann_activationfunc_enum *activation_functions = NULL;
            if (ann != NULL)
            {
                activation_functions = fann_get_cascade_activation_functions(ann);
            }
            return reinterpret_cast<activation_function_enum *>(activation_functions);
        }

        /* Method: set_cascade_activation_functions

           Sets the array of cascade candidate activation functions. The array must be just as long
           as defined by the count.

           See <get_cascade_num_candidates> for a description of which candidate neurons will be 
           generated by this array.

           See also:
   		        <get_cascade_activation_steepnesses_count>, <get_cascade_activation_steepnesses>,
                <fann_set_cascade_activation_functions>

	        This function appears in FANN >= 2.0.0.
         */
        void set_cascade_activation_functions(activation_function_enum *cascade_activation_functions,
            unsigned int cascade_activation_functions_count)
        {
            if (ann != NULL)
            {
                fann_set_cascade_activation_functions(ann,
                    reinterpret_cast<enum fann_activationfunc_enum *>(cascade_activation_functions),
                    cascade_activation_functions_count);
            }
        }
#endif
        /* Method: get_cascade_activation_steepnesses

           The cascade activation steepnesses array is an array of the different activation functions used by
           the candidates.

           See <get_cascade_num_candidates> for a description of which candidate neurons will be 
           generated by this array.

           The default activation steepnesses is {0.25, 0.50, 0.75, 1.00}

           See also:
   		        <set_cascade_activation_steepnesses>, <get_cascade_activation_steepnesses_count>,
                <fann_get_cascade_activation_steepnesses>

	        This function appears in FANN >= 2.0.0.
         */
        helper_array<fann_type> *get_cascade_activation_steepnesses()
        {
            helper_array<fann_type> *activation_steepnesses = NULL;
            if (ann != NULL)
            {
                activation_steepnesses->array_len = fann_get_cascade_activation_steepnesses_count(ann);
                activation_steepnesses->array = fann_get_cascade_activation_steepnesses(ann);
            }
            return activation_steepnesses;
        }																

        /* Method: set_cascade_activation_steepnesses

           Sets the array of cascade candidate activation steepnesses. The array must be just as long
           as defined by the count.

           See <get_cascade_num_candidates> for a description of which candidate neurons will be 
           generated by this array.

           See also:
   		        <get_cascade_activation_steepnesses>, <get_cascade_activation_steepnesses_count>,
                <fann_set_cascade_activation_steepnesses>

	        This function appears in FANN >= 2.0.0.
         */
        void set_cascade_activation_steepnesses(helper_array<fann_type> *cascade_activation_steepnesses)
        {
            if (ann != NULL)
            {
                fann_set_cascade_activation_steepnesses(ann,
                    cascade_activation_steepnesses->array, cascade_activation_steepnesses->array_len);
            }
        }


    };

    /*************************************************************************/
};

#endif /* FANN_CPP_SUBCLASS_H_INCLUDED */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -