Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Nasr
macaon2
Commits
22a16f02
Commit
22a16f02
authored
8 years ago
by
Jeremy Auguste
Browse files
Options
Downloads
Patches
Plain Diff
Working version of cff2fann
parent
173c0056
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
maca_trans_parser/src/cff2fann.c
+30
-21
30 additions, 21 deletions
maca_trans_parser/src/cff2fann.c
with
30 additions
and
21 deletions
maca_trans_parser/src/cff2fann.c
+
30
−
21
View file @
22a16f02
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include
"context.h"
#include
"context.h"
#include
"util.h"
#include
"util.h"
#include
"cf_file.h"
#include
"cf_file.h"
#include
"feat_lib.h"
void
cff2fann_help_message
(
context
*
ctx
)
void
cff2fann_help_message
(
context
*
ctx
)
...
@@ -45,6 +46,7 @@ void one_hot_print(FILE *f, int val, int dim)
...
@@ -45,6 +46,7 @@ void one_hot_print(FILE *f, int val, int dim)
fprintf
(
f
,
"%d "
,
(
i
==
val
)
?
1
:
0
);
fprintf
(
f
,
"%d "
,
(
i
==
val
)
?
1
:
0
);
}
}
void
cff2fann
(
context
*
ctx
)
void
cff2fann
(
context
*
ctx
)
{
{
char
buffer
[
10000
];
char
buffer
[
10000
];
...
@@ -55,40 +57,49 @@ void cff2fann(context *ctx)
...
@@ -55,40 +57,49 @@ void cff2fann(context *ctx)
FILE
*
f
=
myfopen
(
ctx
->
input_filename
,
"r"
);
FILE
*
f
=
myfopen
(
ctx
->
input_filename
,
"r"
);
int
val
;
int
val
;
dico
*
vocab
;
dico
*
vocab
;
char
feature_type
[
64
];
int
feature_valindex
;
int
count
=
0
;
vocab
=
dico_vec_get_dico
(
ctx
->
vocabs
,
"d_perceptron_features"
);
printf
(
"%d %d
\n
"
,
1
,
ctx
->
features_model
->
nbelem
);
while
(
fgets
(
buffer
,
10000
,
f
)){
while
(
fgets
(
buffer
,
10000
,
f
)){
/* printf("%s", buffer); */
/* printf("%s", buffer); */
/* printf("\n"); */
/* printf("\n"); */
token
=
strtok
(
buffer
,
"
\t
"
);
token
=
strtok
(
buffer
,
"
\t
"
);
col_nb
=
0
;
col_nb
=
0
;
if
(
count
%
100
==
0
)
fprintf
(
stderr
,
"%d
\r
"
,
count
);
while
(
token
){
while
(
token
){
/* printf("col = %d token = %s max = %d\n", col_nb, token, max_array[col_nb]); */
/* printf("col = %d token = %s max = %d\n", col_nb, token, max_array[col_nb]); */
val
=
atoi
(
token
);
val
=
atoi
(
token
);
vocab
=
dico_vec_get_dico
(
ctx
->
vocabs
,
"d_perceptron_features"
);
printf
(
"!!! %s
\n
"
,
dico_int2string
(
vocab
,
val
));
if
(
col_nb
==
0
){
if
(
col_nb
==
0
){
one_hot_print
(
std
err
,
val
,
ctx
->
mvt_nb
);
one_hot_print
(
std
out
,
val
,
ctx
->
mvt_nb
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
else
{
else
{
sscanf
(
dico_int2string
(
vocab
,
val
),
"%[^==]==%d"
,
feature_type
,
&
feature_valindex
);
feat_type
=
feat_model_get_type_feat_n
(
ctx
->
features_model
,
col_nb
-
1
);
feat_type
=
feat_model_get_type_feat_n
(
ctx
->
features_model
,
col_nb
-
1
);
/* printf("feat_type = %d\n", feat_type); */
/* printf("feat_type = %d\n", feat_type); */
int
mcd_col
=
m
->
wf2col
[
feat_type
];
int
mcd_col
=
m
->
wf2col
[
feat_type
];
/* printf("representation = %d\n", m->representation[mcd_col]); */
/* printf("representation = %d\n", m->representation[mcd_col]); */
if
(
m
->
representation
[
mcd_col
]
==
MCD_REPRESENTATION_EMB
){
if
(
m
->
representation
[
mcd_col
]
==
MCD_REPRESENTATION_EMB
){
/* printf("it is an embedding val = %d, file = %s\n", val, m->filename[mcd_col]); */
/* printf("it is an embedding val = %d, file = %s\n", val, m->filename[mcd_col]); */
word_emb_print
(
std
err
,
m
->
word_emb_array
[
mcd_col
],
val
);
word_emb_print
(
std
out
,
m
->
word_emb_array
[
mcd_col
],
feature_valindex
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
else
if
(
m
->
representation
[
mcd_col
]
==
MCD_REPRESENTATION_VOCAB
){
if
(
m
->
representation
[
mcd_col
]
==
MCD_REPRESENTATION_VOCAB
){
/* printf("it is a vocab\n"); */
/* printf("it is a vocab\n"); */
one_hot_print
(
std
err
,
val
,
m
->
dico_array
[
mcd_col
]
->
nbelem
);
one_hot_print
(
std
out
,
feature_valindex
,
m
->
dico_array
[
mcd_col
]
->
nbelem
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
else
{
printf
(
"%d
\n
"
,
feature_valindex
);
}
}
}
}
col_nb
++
;
col_nb
++
;
token
=
strtok
(
NULL
,
"
\t
"
);
token
=
strtok
(
NULL
,
"
\t
"
);
}
}
count
++
;
}
}
}
}
...
@@ -110,8 +121,6 @@ int main(int argc, char *argv[])
...
@@ -110,8 +121,6 @@ int main(int argc, char *argv[])
mcd_link_to_dico
(
ctx
->
mcd_struct
,
ctx
->
vocabs
,
1
);
mcd_link_to_dico
(
ctx
->
mcd_struct
,
ctx
->
vocabs
,
1
);
printf
(
"Coucou
\n
"
);
cff2fann
(
ctx
);
cff2fann
(
ctx
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment