私はデバッグしようとしているCのLDAコードを持っており、かなり長時間頭を叩いています。関数から返された値を再割り当てすると、segのエラーが発生する
lda_model *model = NULL;
model = malloc(sizeof(lda_model));
model = quiet_new_lda_model(corpus->num_terms, NTOPICS);
printf ("%f\n", model->alpha); // Segfaults here
我々はquiet_new_lda_model
機能と、元の発信者間の取引で問題になる可能性がどのようなモデル作成機能
lda_model* quiet_new_lda_model(int num_terms, int num_topics) {
int i;
lda_model* model;
model = malloc(sizeof(lda_model));
model->num_topics = num_topics;
model->num_terms = num_terms;
model->alpha = 1.0;
printf ("%f\n", model->alpha); // Prints 1.0
model->log_prob_w = malloc(sizeof(double*)*num_topics);
for (i = 0; i < num_topics; i++)
{
model->log_prob_w[i] = malloc(sizeof(double)*num_terms);
memset(model->log_prob_w[i],0,sizeof(double)*num_terms);
}
printf ("%f\n", model->alpha); // Prints 1.0
return(model);
}
を見れば?
ありがとうございます!
ない故障のためのmalloc()をチェックするファン役立ちますchange..Maybeのための「%のF」とは対照的に「%ldの」を使用してみてください、私は...見 – Josh
コメントアウトモデル - > log_prog_wを扱うコードがまだクラッシュするかどうかを確認してください – James