view release on metacpan or search on metacpan
ccv-src/bin/cifar-10.c view on Meta::CPAN
layer_params[8].w.decay = 0.01;
layer_params[8].w.learn_rate = 0.001;
layer_params[8].w.momentum = 0.9;
layer_params[8].bias.decay = 0;
layer_params[8].bias.learn_rate = 0.001;
layer_params[8].bias.momentum = 0.9;
ccv_convnet_train_param_t params = {
.max_epoch = 999,
.mini_batch = 128,
.iterations = 500,
.symmetric = 1,
.color_gain = 0,
.device_count = 1,
.layer_params = layer_params,
};
ccv_convnet_supervised_train(convnet, categorizeds, tests, "cifar-10.sqlite3", params);
}
if (r1)
fclose(r1);
if (r2)
ccv-src/bin/dpmcreate.c view on Meta::CPAN
" --positive-list : text file contains a list of positive files in format:\n"
" <file name> x y width height \\newline\n"
" --background-list : text file contains a list of image files that don't contain any target objects\n"
" --negative-count : the number of negative examples we should collect from background files to initialize SVM\n"
" --model-component : the number of root filters in our mixture model\n"
" --model-part : the number of part filters for each root filter\n"
" --working-dir : the directory to save progress and produce result model\n"
" --symmetric : 0 or 1, whether to exploit symmetric property of the object\n\n"
" \033[1mOTHER OPTIONS\033[0m\n\n"
" --base-dir : change the base directory so that the program can read images from there\n"
" --iterations : how many iterations are needed for stochastic gradient descent [DEFAULT TO 1000]\n"
" --root-relabels : how many relabel procedures are needed for root model optimization [DEFAULT TO 20]\n"
" --data-minings : how many data mining procedures are needed for discovering hard examples [DEFAULT TO 50]\n"
" --relabels : how many relabel procedures are needed for part model optimization [DEFAULT TO 10]\n"
" --alpha : the step size for stochastic gradient descent [DEFAULT TO 0.01]\n"
" --alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.995]\n"
" --margin-c : the famous C in SVM [DEFAULT TO 0.002]\n"
" --balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.5]\n"
" --negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 2000]\n"
" --include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
" --grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 0]\n"
ccv-src/bin/dpmcreate.c view on Meta::CPAN
"\t--positive-list : text file contains a list of positive files in format:\n"
"\t <file name> x y width height \\newline\n"
"\t--background-list : text file contains a list of image files that don't contain any target objects\n"
"\t--negative-count : the number of negative examples we should collect from background files to initialize SVM\n"
"\t--model-component : the number of root filters in our mixture model\n"
"\t--model-part : the number of part filters for each root filter\n"
"\t--working-dir : the directory to save progress and produce result model\n"
"\t--symmetric : 0 or 1, whether to exploit symmetric property of the object\n\n"
"\033[1mOTHER OPTIONS\033[0m\n"
"\t--base-dir : change the base directory so that the program can read images from there\n"
"\t--iterations : how many iterations needed for stochastic gradient descent [DEFAULT TO 20]\n"
"\t--relabels : how many relabel procedure needed [DEFAULT TO 5]\n"
"\t--alpha : the step size for stochastic gradient descent [DEFAULT TO 0.1]\n"
"\t--alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.9]\n"
"\t--margin-c : the famous C in SVM [DEFAULT TO 0.002]\n"
"\t--balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.75]\n"
"\t--negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 500]\n"
"\t--include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
"\t--exclude-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Below this threshold, it is ensured to not be the same object [DEFAULT TO 0.5]\n"
"\t--grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 1]\n"
"\t--percentile-breakdown : 0.00 - 1.00, the percentile use for breakdown threshold [DEFAULT TO 0.05]\n"
ccv-src/bin/dpmcreate.c view on Meta::CPAN
/* required parameters */
{"positive-list", 1, 0, 0},
{"background-list", 1, 0, 0},
{"working-dir", 1, 0, 0},
{"negative-count", 1, 0, 0},
{"model-component", 1, 0, 0},
{"model-part", 1, 0, 0},
{"symmetric", 1, 0, 0},
/* optional parameters */
{"base-dir", 1, 0, 0},
{"iterations", 1, 0, 0},
{"root-relabels", 1, 0, 0},
{"data-minings", 1, 0, 0},
{"relabels", 1, 0, 0},
{"alpha", 1, 0, 0},
{"alpha-ratio", 1, 0, 0},
{"balance", 1, 0, 0},
{"negative-cache-size", 1, 0, 0},
{"margin-c", 1, 0, 0},
{"percentile-breakdown", 1, 0, 0},
{"include-overlap", 1, 0, 0},
ccv-src/bin/dpmcreate.c view on Meta::CPAN
ccv_dpm_new_param_t params = {
.components = 0,
.detector = detector,
.parts = 0,
.min_area = 3000,
.max_area = 5000,
.symmetric = 1,
.alpha = 0.01,
.balance = 1.5,
.alpha_ratio = 0.995,
.iterations = 1000,
.data_minings = 50,
.root_relabels = 20,
.relabels = 10,
.negative_cache_size = 2000,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
.grayscale = 0,
.discard_estimating_constant = 1,
};
=======
ccv_dpm_new_param_t params = { .components = 0,
.detector = detector,
.parts = 0,
.min_area = 3000,
.max_area = 5000,
.symmetric = 1,
.alpha = 0.1,
.balance = 1.75,
.alpha_ratio = 0.9,
.iterations = 20,
.relabels = 5,
.negative_cache_size = 500,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
.exclude_overlap = 0.1,
.grayscale = 0 };
>>>>>>> added a simple config script
int i, k;
while (getopt_long_only(argc, argv, "", dpm_options, &k) != -1)
ccv-src/bin/dpmcreate.c view on Meta::CPAN
case 6:
params.parts = atoi(optarg);
break;
case 7:
params.symmetric = !!atoi(optarg);
break;
case 8:
base_dir = optarg;
break;
case 9:
params.iterations = atoi(optarg);
break;
case 10:
params.root_relabels = atoi(optarg);
break;
case 11:
params.data_minings = atoi(optarg);
case 12:
params.relabels = atoi(optarg);
break;
case 13:
ccv-src/bin/image-net.c view on Meta::CPAN
"\n \033[1mUSAGE\033[0m\n\n image-net [OPTION...]\n\n"
" \033[1mREQUIRED OPTIONS\033[0m\n\n"
" --train-list : text file contains a list of image files in format:\n"
" class-label <file name>\\newline\n"
" --test-list : text file contains a list of image files in format:\n"
" class-label <file name>\\newline\n"
" --working-dir : the directory to save progress and produce result model\n\n"
" \033[1mOTHER OPTIONS\033[0m\n\n"
" --base-dir : change the base directory so that the program can read images from there\n"
" --max-epoch : how many epoch are needed for stochastic gradient descent (an epoch corresponds to go through the full train list) [DEFAULT TO 100]\n"
" --iterations : how many iterations are needed for stochastic gradient descent (an iteration corresponds to go through a mini batch) [DEFAULT TO 5000]\n\n"
);
exit(0);
}
int main(int argc, char** argv)
{
static struct option image_net_options[] = {
/* help */
{"help", 0, 0, 0},
/* required parameters */
{"train-list", 1, 0, 0},
{"test-list", 1, 0, 0},
{"working-dir", 1, 0, 0},
/* optional parameters */
{"base-dir", 1, 0, 0},
{"max-epoch", 1, 0, 0},
{"iterations", 1, 0, 0},
{0, 0, 0, 0}
};
char* train_list = 0;
char* test_list = 0;
char* working_dir = 0;
char* base_dir = 0;
ccv_convnet_train_param_t train_params = {
.max_epoch = 100,
.mini_batch = 64,
.sgd_frequency = 1, // do sgd every sgd_frequency batches (mini_batch * device_count * sgd_frequency)
.iterations = 50000,
.device_count = 4,
.peer_access = 1,
.symmetric = 1,
.image_manipulation = 0.2,
.color_gain = 0.001,
.input = {
.min_dim = 257,
.max_dim = 257,
},
};
ccv-src/bin/image-net.c view on Meta::CPAN
case 3:
working_dir = optarg;
break;
case 4:
base_dir = optarg;
break;
case 5:
train_params.max_epoch = atoi(optarg);
break;
case 6:
train_params.iterations = atoi(optarg);
break;
}
}
if (!train_list || !test_list || !working_dir)
exit_with_help();
ccv_enable_default_cache();
FILE *r0 = fopen(train_list, "r");
assert(r0 && "train-list doesn't exists");
FILE* r1 = fopen(test_list, "r");
assert(r1 && "test-list doesn't exists");
ccv-src/bin/swtcreate.c view on Meta::CPAN
" --thickness-ratio : the maximal allowance of thickness change between two letters [DEFAULT TO 1,0.1,2]\n"
" --height-ratio : the maximal allowance of height change between two letters [DEFAULT TO 1,0.1,3]\n"
" --intensity-thresh : how much intensity tolerance between two letters [DEFAULT TO 1,1,50]\n"
" --letter-occlude-thresh : how many letters one letter rectangle can occlude [DEFAULT TO 0,1,5]\n"
" --distance-ratio : the distance between two letters comparing to their width [DEFAULT TO 1,0.1,5]\n"
" --intersect-ratio : how much in the y-axis two letters intersect with each other [DEFAULT TO 0,0.1,5]\n"
" --letter-thresh : how many letters in minimal should one text line contains [DEFAULT TO 0,1,5]\n"
" --elongate-ratio : what's the minimal ratio between text line's width and height [DEFAULT TO 0.1,0.1,2.5]\n"
" --breakdown-ratio : what's the ratio for text line to break down into words [DEFAULT TO 0.5,0.01,1.5]\n"
" --breakdown : support to break text lines down to words [DEFAULT TO 1]\n"
" --iterations : how many iterations for the search [DEFAULT TO 10]\n"
" --base-dir : change the base directory so that the program can read images from there\n"
);
exit(-1);
}
static double one_g = 0.8;
static double one_d = 0.4;
static double om_one = 0.8;
static double center_diff_thr = 1.0;
ccv-src/bin/swtcreate.c view on Meta::CPAN
{"thickness-ratio", 1, 0, 0},
{"height-ratio", 1, 0, 0},
{"intensity-thresh", 1, 0, 0},
{"letter-occlude-thresh", 1, 0, 0},
{"distance-ratio", 1, 0, 0},
{"intersect-ratio", 1, 0, 0},
{"letter-thresh", 1, 0, 0},
{"elongate-ratio", 1, 0, 0},
{"breakdown-ratio", 1, 0, 0},
{"breakdown", 1, 0, 0},
{"iterations", 1, 0, 0},
{"base-dir", 1, 0, 0},
{0, 0, 0, 0}
};
if (argc <= 1)
exit_with_help();
ccv_swt_param_t params = {
.interval = 1,
.same_word_thresh = { 0.2, 0.8 },
.min_neighbors = 1,
.scale_invariant = 0,
ccv-src/bin/swtcreate.c view on Meta::CPAN
.max_value = 2.5,
.step = 0.1,
.enable = 1,
};
ccv_swt_range_t breakdown_ratio_range = {
.min_value = 0.5,
.max_value = 1.5,
.step = 0.01,
.enable = 1,
};
int i, j, k, iterations = 10;
while (getopt_long_only(argc - 1, argv + 1, "", swt_options, &k) != -1)
{
switch (k)
{
case 0:
exit_with_help();
case 1:
decode_range(optarg, &size_range);
break;
case 2:
ccv-src/bin/swtcreate.c view on Meta::CPAN
case 16:
decode_range(optarg, &elongate_ratio_range);
break;
case 17:
decode_range(optarg, &breakdown_ratio_range);
break;
case 18:
params.breakdown = !!atoi(optarg);
break;
case 19:
iterations = atoi(optarg);
break;
case 20:
chdir(optarg);
break;
}
}
FILE* r = fopen(argv[1], "rt");
if (!r)
exit_with_help();
ccv_enable_cache(1024 * 1024 * 1024);
ccv-src/bin/swtcreate.c view on Meta::CPAN
if (high_thresh_range.enable)
printf(" - canny high threshold from %d to %d, += %lg\n", (int)(high_thresh_range.min_value + 0.5), (int)(high_thresh_range.max_value + 0.5), high_thresh_range.step);
double best_f = 0, best_precision = 0, best_recall = 0;
double a = 0.5;
double v;
ccv_swt_param_t best_params = params;
#define optimize(parameter, type, rounding) \
if (parameter##_range.enable) \
{ \
params = best_params; \
int total_iterations = 0; \
for (v = parameter##_range.min_value; v <= parameter##_range.max_value; v += parameter##_range.step) \
++total_iterations; \
double* precision = (double*)ccmalloc(sizeof(double) * total_iterations); \
double* recall = (double*)ccmalloc(sizeof(double) * total_iterations); \
double* total_words = (double*)ccmalloc(sizeof(double) * total_iterations); \
memset(precision, 0, sizeof(double) * total_iterations); \
memset(recall, 0, sizeof(double) * total_iterations); \
memset(total_words, 0, sizeof(double) * total_iterations); \
double total_truth = 0; \
for (j = 0; j < aof->rnum; j++) \
{ \
char* name = *(char**)ccv_array_get(aof, j); \
ccv_dense_matrix_t* image = 0; \
ccv_read(name, &image, CCV_IO_GRAY | CCV_IO_ANY_FILE); \
ccv_array_t* truth = *(ccv_array_t**)ccv_array_get(aow, j); \
total_truth += truth->rnum; \
for (v = parameter##_range.min_value, k = 0; v <= parameter##_range.max_value; v += parameter##_range.step, k++) \
{ \
ccv-src/bin/swtcreate.c view on Meta::CPAN
best_precision = total_precision; \
best_recall = total_recall; \
} \
FLUSH(CCV_CLI_INFO, "current harmonic mean : %.2lf%%, precision : %.2lf%%, recall : %.2lf%% ; best harmonic mean : %.2lf%%, precision : %.2lf%%, recall : %.2lf%% ; at " #parameter " = %lg (%lg <- [%lg, %lg])", f * 100, total_precision * 100, total...
} \
printf("\n"); \
ccfree(precision); \
ccfree(recall); \
ccfree(total_words); \
}
for (i = 0; i < iterations; i++)
{
optimize(size, int, 0.5);
optimize(std_ratio, double, 0);
optimize(max_height, int, 0.5);
optimize(min_height, int, 0.5);
optimize(min_area, int, 0.5);
optimize(letter_occlude_thresh, int, 0.5);
optimize(aspect_ratio, double, 0);
optimize(thickness_ratio, double, 0);
optimize(height_ratio, double, 0);
ccv-src/bin/swtcreate.c view on Meta::CPAN
"\taspect_ratio = %lf\n"
"\tstd_ratio = %lf\n"
"\tthickness_ratio = %lf\n"
"\theight_ratio = %lf\n"
"\tintensity_thresh = %d\n"
"\tdistance_ratio = %lf\n"
"\tintersect_ratio = %lf\n"
"\tletter_thresh = %d\n"
"\telongate_ratio = %lf\n"
"\tbreakdown_ratio = %lf\n",
i + 1, iterations,
best_params.size,
best_params.low_thresh,
best_params.high_thresh,
best_params.max_height,
best_params.min_height,
best_params.min_area,
best_params.letter_occlude_thresh,
best_params.aspect_ratio,
best_params.std_ratio,
best_params.thickness_ratio,
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
int nTableLock; /* Number of locks in aTableLock */
TableLock *aTableLock; /* Required table locks for shared-cache mode */
#endif
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
/* Information used while coding trigger programs. */
Parse *pToplevel; /* Parse structure for main program (or NULL) */
Table *pTriggerTab; /* Table triggers are being coded for */
int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */
int addrSkipPK; /* Address of instruction to skip PRIMARY KEY index */
u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
u32 oldmask; /* Mask of old.* columns referenced */
u32 newmask; /* Mask of new.* columns referenced */
u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
u8 disableTriggers; /* True to disable triggers */
/* Above is constant between recursions. Below is reset before and after
** each recursion */
int nVar; /* Number of '?' variables seen in the SQL so far */
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
int i; /* Loop counter */
int mxBitCol; /* Maximum column in pSrc->colUsed */
CollSeq *pColl; /* Collating sequence to on a column */
WhereLoop *pLoop; /* The Loop object */
char *zNotUsed; /* Extra space on the end of pIdx */
Bitmask idxCols; /* Bitmap of columns used for indexing */
Bitmask extraCols; /* Bitmap of additional columns */
u8 sentWarning = 0; /* True if a warnning has been issued */
/* Generate code to skip over the creation and initialization of the
** transient index on 2nd and subsequent iterations of the loop. */
v = pParse->pVdbe;
assert( v!=0 );
addrInit = sqlite3CodeOnce(pParse);
/* Count the number of columns that will be added to the index
** and used to match WHERE clause constraints */
nKeyCol = 0;
pTable = pSrc->pTab;
pWCEnd = &pWC->a[pWC->nTerm];
pLoop = pLevel->pWLoop;
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
** We have so far matched pBuilder->pNew->u.btree.nEq terms of the index pIndex.
** Try to match one more.
**
** If pProbe->tnum==0, that means pIndex is a fake index used for the
** INTEGER PRIMARY KEY.
*/
static int whereLoopAddBtreeIndex(
WhereLoopBuilder *pBuilder, /* The WhereLoop factory */
struct SrcList_item *pSrc, /* FROM clause term being analyzed */
Index *pProbe, /* An index on pSrc */
LogEst nInMul /* log(Number of iterations due to IN) */
){
WhereInfo *pWInfo = pBuilder->pWInfo; /* WHERE analyse context */
Parse *pParse = pWInfo->pParse; /* Parsing context */
sqlite3 *db = pParse->db; /* Database connection malloc context */
WhereLoop *pNew; /* Template WhereLoop under construction */
WhereTerm *pTerm; /* A WhereTerm under consideration */
int opMask; /* Valid operators for constraints */
WhereScan scan; /* Iterator for WHERE terms */
Bitmask saved_prereq; /* Original value of pNew->prereq */
u16 saved_nLTerm; /* Original value of pNew->nLTerm */
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
aTo = (WherePath*)pSpace;
aFrom = aTo+mxChoice;
memset(aFrom, 0, sizeof(aFrom[0]));
pX = (WhereLoop**)(aFrom+mxChoice);
for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){
pFrom->aLoop = pX;
}
/* Seed the search with a single WherePath containing zero WhereLoops.
**
** TUNING: Do not let the number of iterations go above 25. If the cost
** of computing an automatic index is not paid back within the first 25
** rows, then do not use the automatic index. */
aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
nFrom = 1;
/* Precompute the cost of sorting the final result set, if the caller
** to sqlite3WhereBegin() was concerned about sorting */
rSortCost = 0;
if( pWInfo->pOrderBy==0 || nRowEst==0 ){
aFrom[0].isOrderedValid = 1;
ccv-src/lib/ccv.h view on Meta::CPAN
* solution. Thus, "invert" would be classified as numerical because of the sense that in some case,
* it can only be "approximate" (in least-square sense), so to "solve". */
void ccv_invert(ccv_matrix_t* a, ccv_matrix_t** b, int type);
void ccv_solve(ccv_matrix_t* a, ccv_matrix_t* b, ccv_matrix_t** d, int type);
void ccv_eigen(ccv_dense_matrix_t* a, ccv_dense_matrix_t** vector, ccv_dense_matrix_t** lambda, int type, double epsilon);
typedef struct {
double interp; /**< Interpolate value. */
double extrap; /**< Extrapolate value. */
int max_iter; /**< Maximum iterations. */
double ratio; /**< Increase ratio. */
double rho; /**< Decrease ratio. */
double sig; /**< Sigma. */
} ccv_minimize_param_t;
extern const ccv_minimize_param_t ccv_minimize_default_params;
typedef int(*ccv_minimize_f)(const ccv_dense_matrix_t* x, double* f, ccv_dense_matrix_t* df, void*);
/**
* Linear-search to minimize function with partial derivatives. It is formed after [minimize.m](http://www.gatsby.ucl.ac.uk/~edward/code/minimize/example.html).
ccv-src/lib/ccv.h view on Meta::CPAN
float threshold; /**< The threshold the determines the acceptance of an object. */
} ccv_dpm_param_t;
typedef struct {
int components; /**< The number of root filters in the mixture model. */
int parts; /**< The number of part filters for each root filter. */
int grayscale; /**< Whether to exploit color in a given image. */
int symmetric; /**< Whether to exploit symmetric property of the object. */
int min_area; /**< The minimum area that one part classifier can occupy, 3000 is a reasonable number. */
int max_area; /**< The maximum area that one part classifier can occupy. 5000 is a reasonable number. */
int iterations; /**< How many iterations needed for stochastic gradient descent. */
int data_minings; /**< How many data mining procedures are needed for discovering hard examples. */
int root_relabels; /**< How many relabel procedures for root classifier are needed. */
int relabels; /**< How many relabel procedures are needed. */
int discard_estimating_constant; // 1
int negative_cache_size; /**< The cache size for negative examples. 1000 is a reasonable number. */
double include_overlap; /**< The percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object. 0.7 is a reasonable number. */
double alpha; /**< The step size for stochastic gradient descent. */
double alpha_ratio; /**< Decrease the step size for each iteration. 0.85 is a reasonable number. */
double balance; /**< To balance the weight of positive examples and negative examples. 1.5 is a reasonable number. */
double C; /**< C in SVM. */
ccv-src/lib/ccv.h view on Meta::CPAN
// is used in real-world, I simply need to multiply its weights to 1 - dor
// to get the real one)
float dor; /**< The dropout rate for this layer, it is only applicable for full connect layer. */
ccv_convnet_layer_sgd_param_t w; /**< A **ccv_convnet_layer_sgd_param_t** specifies the stochastic gradient descent update rule for weight, it is only applicable for full connect layer and convolutional layer. */
ccv_convnet_layer_sgd_param_t bias; /**< A **ccv_convnet_layer_sgd_param_t** specifies the stochastic gradient descent update rule for bias, it is only applicable for full connect layer and convolutional layer weight. */
} ccv_convnet_layer_train_param_t;
typedef struct {
int max_epoch; /**< The number of epoch (an epoch sweeps through all the examples) to go through before end the training. */
int mini_batch; /**< The number of examples for a batch in stochastic gradient descent. */
int iterations; /**< The number of iterations (an iteration is for one batch) before save the progress. */
int sgd_frequency; /**< After how many batches when we do a SGD update. */
int symmetric; /**< Whether to exploit the symmetric property of the provided examples. */
int device_count; /**< Use how many GPU devices, this is capped by available CUDA devices on your system. For now, ccv's implementation only support up to 4 GPUs */
int peer_access; /**< Enable peer access for cross device communications or not, this will enable faster multiple device training. */
float image_manipulation; /**< The value for image brightness / contrast / saturation manipulations. */
float color_gain; /**< The color variance for data augmentation (0 means no such augmentation). */
struct {
int min_dim; /**< [input.min_dim] The minimum dimensions for random resize of training images. */
int max_dim; /**< [input.max_dim] The maximum dimensions for random resize of training images. */
} input;
ccv-src/lib/ccv.h view on Meta::CPAN
void ccv_convnet_compact(ccv_convnet_t* convnet);
/**
* Free up the memory of a given convolutional network.
* @param convnet A convolutional network.
*/
void ccv_convnet_free(ccv_convnet_t* convnet);
/** @} */
/* add for command-line outputs, b/c ccv's training steps has a ton of outputs,
* and in the future, it can be piped into callback functions for critical information
* (such as the on-going missing rate, or iterations etc.) */
enum {
CCV_CLI_ERROR = 1 << 2,
CCV_CLI_INFO = 1 << 1,
CCV_CLI_VERBOSE = 1,
CCV_CLI_NONE = 0,
};
int ccv_cli_output_level_and_above(int level);
void ccv_cli_set_output_levels(int level);
ccv-src/lib/ccv_bbf.c view on Meta::CPAN
#endif
for (i = 0; i < pnum; i++)
gene[i].error = _ccv_bbf_error_rate(&gene[i].feature, posdata, posnum, negdata, negnum, size, pw, nw);
timer = _ccv_bbf_time_measure() - timer;
for (i = 0; i < pnum; i++)
_ccv_bbf_genetic_fitness(&gene[i]);
double best_err = 1;
int rnum = ftnum * 39; /* number of randomize */
int mnum = ftnum * 40; /* number of mutation */
int hnum = ftnum * 20; /* number of hybrid */
/* iteration stop crit : best no change in 40 iterations */
int it = 0, t;
for (t = 0 ; it < 40; ++it, ++t)
{
int min_id = 0;
double min_err = gene[0].error;
for (i = 1; i < pnum; i++)
if (gene[i].error < min_err)
{
min_id = i;
min_err = gene[i].error;
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
}
static void _ccv_dpm_check_params(ccv_dpm_new_param_t params)
{
assert(params.components > 0);
assert(params.parts > 0);
assert(params.grayscale == 0 || params.grayscale == 1);
assert(params.symmetric == 0 || params.symmetric == 1);
assert(params.min_area > 100);
assert(params.max_area > params.min_area);
assert(params.iterations >= 0);
assert(params.data_minings >= 0);
assert(params.relabels >= 0);
assert(params.negative_cache_size > 0);
assert(params.include_overlap > 0.1);
assert(params.alpha > 0 && params.alpha < 1);
assert(params.alpha_ratio > 0 && params.alpha_ratio < 1);
assert(params.C > 0);
assert(params.balance > 0);
assert(params.percentile_breakdown > 0 && params.percentile_breakdown <= 1);
assert(params.detector.interval > 0);
}
#define MINI_BATCH (10)
#define REGQ (100)
static ccv_dpm_mixture_model_t* _ccv_dpm_optimize_root_mixture_model(gsl_rng* rng, ccv_dpm_mixture_model_t* model, ccv_array_t** posex, ccv_array_t** negex, int relabels, double balance, double C, double previous_alpha, double alpha_ratio, int iterat...
{
int i, j, k, t, c;
for (i = 0; i < model->count - 1; i++)
assert(posex[i]->rnum == posex[i + 1]->rnum && negex[i]->rnum == negex[i + 1]->rnum);
int posnum = posex[0]->rnum;
int negnum = negex[0]->rnum;
int* label = (int*)ccmalloc(sizeof(int) * (posnum + negnum));
int* order = (int*)ccmalloc(sizeof(int) * (posnum + negnum));
double previous_positive_loss = 0, previous_negative_loss = 0, positive_loss = 0, negative_loss = 0, loss = 0;
double regz_rate = C;
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
label[i + posnum] = best;
++neg_prog[best];
}
PRINT(CCV_CLI_INFO, " - negative examples divided by components for root model optimizing : %d", neg_prog[0]);
for (i = 1; i < model->count; i++)
PRINT(CCV_CLI_INFO, ", %d", neg_prog[i]);
PRINT(CCV_CLI_INFO, "\n");
ccv_dpm_mixture_model_t* _model;
double alpha = previous_alpha;
previous_positive_loss = previous_negative_loss = 0;
for (t = 0; t < iterations; t++)
{
for (i = 0; i < posnum + negnum; i++)
order[i] = i;
gsl_ran_shuffle(rng, order, posnum + negnum, sizeof(int));
for (j = 0; j < model->count; j++)
{
double pos_weight = sqrt((double)neg_prog[j] / pos_prog[j] * balance); // positive weight
double neg_weight = sqrt((double)pos_prog[j] / neg_prog[j] / balance); // negative weight
_model = _ccv_dpm_model_copy(model);
int l = 0;
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
double score = _ccv_dpm_vector_score(model, v);
assert(!isnan(score));
double hinge_loss = ccv_max(0, 1.0 + score);
negative_loss += hinge_loss;
double neg_weight = sqrt((double)pos_prog[v->id] / neg_prog[v->id] / balance); // negative weight
loss += neg_weight * hinge_loss;
}
loss = loss / (posvn + negnum);
positive_loss = positive_loss / posvn;
negative_loss = negative_loss / negnum;
FLUSH(CCV_CLI_INFO, " - with loss %.5lf (positive %.5lf, negative %.5f) at rate %.5lf %d | %d -- %d%%", loss, positive_loss, negative_loss, alpha, posvn, negnum, (t + 1) * 100 / iterations);
// check symmetric property of generated root feature
if (symmetric)
for (i = 0; i < model->count; i++)
{
ccv_dpm_root_classifier_t* root_classifier = model->root + i;
_ccv_dpm_check_root_classifier_symmetry(root_classifier->root.w);
}
if (fabs(previous_positive_loss - positive_loss) < 1e-5 &&
fabs(previous_negative_loss - negative_loss) < 1e-5)
{
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
int t, d, c, i, j, k, p;
_ccv_dpm_check_params(params);
assert(params.negative_cache_size <= negnum && params.negative_cache_size > REGQ && params.negative_cache_size > MINI_BATCH);
PRINT(CCV_CLI_INFO, "with %d positive examples and %d negative examples\n"
"negative examples are are going to be collected from %d background images\n",
posnum, negnum, bgnum);
PRINT(CCV_CLI_INFO, "use symmetric property? %s\n", params.symmetric ? "yes" : "no");
PRINT(CCV_CLI_INFO, "use color? %s\n", params.grayscale ? "no" : "yes");
PRINT(CCV_CLI_INFO, "negative examples cache size : %d\n", params.negative_cache_size);
PRINT(CCV_CLI_INFO, "%d components and %d parts\n", params.components, params.parts);
PRINT(CCV_CLI_INFO, "expected %d root relabels, %d relabels, %d data minings and %d iterations\n", params.root_relabels, params.relabels, params.data_minings, params.iterations);
PRINT(CCV_CLI_INFO, "include overlap : %lf\n"
"alpha : %lf\n"
"alpha decreasing ratio : %lf\n"
"C : %lf\n"
"balance ratio : %lf\n"
"------------------------\n",
params.include_overlap, params.alpha, params.alpha_ratio, params.C, params.balance);
gsl_rng_env_setup();
gsl_rng* rng = gsl_rng_alloc(gsl_rng_default);
gsl_rng_set(rng, *(unsigned long int*)¶ms);
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
if (params.symmetric)
for (i = 0; i < params.components; i++)
{
ccv_dpm_root_classifier_t* root_classifier = model->root + i;
_ccv_dpm_check_root_classifier_symmetry(root_classifier->root.w);
}
if (params.components > 1)
{
/* TODO: coordinate-descent for lsvm */
PRINT(CCV_CLI_INFO, "optimizing root mixture model with coordinate-descent approach\n");
model = _ccv_dpm_optimize_root_mixture_model(rng, model, posex, negex, params.root_relabels, params.balance, params.C, params.alpha, params.alpha_ratio, params.iterations, params.symmetric);
} else {
PRINT(CCV_CLI_INFO, "components == 1, skipped coordinate-descent to optimize root mixture model\n");
}
for (i = 0; i < params.components; i++)
{
for (j = 0; j < posex[i]->rnum; j++)
_ccv_dpm_feature_vector_cleanup((ccv_dpm_feature_vector_t*)ccv_array_get(posex[i], j));
ccv_array_free(posex[i]);
for (j = 0; j < negex[i]->rnum; j++)
_ccv_dpm_feature_vector_cleanup((ccv_dpm_feature_vector_t*)ccv_array_get(negex[i], j));
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
_ccv_dpm_adjust_model_constant(model, i, posv, posnum, params.percentile_breakdown);
continue;
}
PRINT(CCV_CLI_INFO, " - negative examples divided by components : %d", negvnum[0]);
for (i = 1; i < model->count; i++)
PRINT(CCV_CLI_INFO, ", %d", negvnum[i]);
PRINT(CCV_CLI_INFO, "\n");
previous_positive_loss = previous_negative_loss = 0;
uint64_t elapsed_time = _ccv_dpm_time_measure();
assert(negv->rnum < params.negative_cache_size + 64);
for (t = 0; t < params.iterations; t++)
{
for (p = 0; p < model->count; p++)
{
// if don't have enough negnum or posnum, aborting
if (negvnum[p] <= ccv_max(params.negative_cache_size / (model->count * 3), ccv_max(REGQ, MINI_BATCH)) ||
posvnum[p] <= ccv_max(REGQ, MINI_BATCH))
continue;
double pos_weight = sqrt((double)negvnum[p] / posvnum[p] * params.balance); // positive weight
double neg_weight = sqrt((double)posvnum[p] / negvnum[p] / params.balance); // negative weight
_model = _ccv_dpm_model_copy(model);
ccv-src/lib/ccv_dpm.c view on Meta::CPAN
double score = _ccv_dpm_vector_score(model, v);
assert(!isnan(score));
double hinge_loss = ccv_max(0, 1.0 + score);
negative_loss += hinge_loss;
double neg_weight = sqrt((double)posvnum[v->id] / negvnum[v->id] / params.balance); // negative weight
loss += neg_weight * hinge_loss;
}
loss = loss / (posvn + negv->rnum);
positive_loss = positive_loss / posvn;
negative_loss = negative_loss / negv->rnum;
FLUSH(CCV_CLI_INFO, " - with loss %.5lf (positive %.5lf, negative %.5f) at rate %.5lf %d | %d -- %d%%", loss, positive_loss, negative_loss, alpha, posvn, negv->rnum, (t + 1) * 100 / params.iterations);
// check symmetric property of generated root feature
if (params.symmetric)
for (i = 0; i < params.components; i++)
{
ccv_dpm_root_classifier_t* root_classifier = model->root + i;
_ccv_dpm_check_root_classifier_symmetry(root_classifier->root.w);
}
if (fabs(previous_positive_loss - positive_loss) < 1e-5 &&
fabs(previous_negative_loss - negative_loss) < 1e-5)
{
ccv-src/lib/ccv_internal.h view on Meta::CPAN
/* simple utility functions */
#define ccv_descale(x, n) (((x) + (1 << ((n) - 1))) >> (n))
#define conditional_assert(x, expr) if ((x)) { assert(expr); }
#define MACRO_STRINGIFY(x) #x
#define UNROLL_PRAGMA0(x) MACRO_STRINGIFY(unroll x)
#define UNROLL_FOR0(x, s, ss, ...) _Pragma(UNROLL_PRAGMA0((ss))) for ((x) = 0; (x) < (s); (x)++) {
/* How to use this:
* unroll_for(i, the number of iterations, the number of unrolls)
* Or
* unroll_for(i, the number of iterations)
*/
#define unroll_for(x, s, ...) UNROLL_FOR0(x, s, ##__VA_ARGS__, s)
#define unroll_endfor }
#ifdef USE_OPENMP
#define OMP_PRAGMA0(x) MACRO_STRINGIFY(omp parallel for private(x) schedule(dynamic))
#define parallel_for(x, n) { int x; _Pragma(OMP_PRAGMA0(x)) for ((x) = 0; (x) < (n); (x)++) {
#define parallel_endfor } }
#define FOR_IS_PARALLEL (1)
#elif defined(USE_DISPATCH) // Convert from size_t to int such that we avoid unsigned, and keep it consistent with the rest of parallel_for
ccv-src/serve/ebb.c view on Meta::CPAN
* Resets the timeout to stay alive for another connection->timeout seconds
*/
void
ebb_connection_reset_timeout(ebb_connection *connection)
{
ev_timer_again(connection->server->loop, &connection->timeout_watcher);
}
/**
* Writes a string to the socket. This is actually sets a watcher
* which may take multiple iterations to write the entire string.
*
* The buf->on_release() callback will be made when the operation is complete.
*
* This can only be called once at a time. If you call it again
* while the connection is writing another buffer the ebb_connection_write
* will return 0 and ignore the request.
*/
int
ebb_connection_write(ebb_connection *connection, const char *buf, size_t len, ebb_after_write_cb cb)
{