Yes, thanks. Apparently, that function is only available in the git repo and not in the latest release, but it kind of works now. However, it looks to me that the underlying c function will make a copy of the Julia data anyway (see https://github.com/libfann/fann/blob/master/src/fann_train_data.c at line 854).
Question: How can I get Julia code review? Thanks, Davide On Saturday, October 25, 2014 3:43:56 PM UTC+1, Isaiah wrote: > > I missed this but it looks like you got it sorted, yes? Using > fann_create_train_array > and taking pointers to the Julia array will save a lot of copying so is > definitely the right way to go. > > On Tue, Oct 21, 2014 at 6:47 PM, Davide Lasagna <[email protected] > <javascript:>> wrote: > >> Hi all, >> >> I am currently working on Neural Networks and I wanted to wrap the FANN >> C library <http://leenissen.dk/fann/wp/> using Julia. I just started my >> work so things are spread around in bits and pieces. I have first wrapped >> the library using Clang.jl to automatically generate the Julia wrappers >> from the headers. I then started to create a wrapper code around a C struct >> which will contain references to the training data, and immediately had an >> issue. >> >> I moved the relevant part of my code to this gist >> <https://gist.github.com/gasagna/ba8c39c8f8ad63fd1d6d>. In data.jl, the >> fann_train_data is a julia type created by Clang and contains two pointers >> to pointers for the input and output data for the training. The rest of >> data.jl contains the definition of the DataSet type, which will be the >> central part of the package. As you can see, at line 42 a ccall to >> fann_create_train in libfann (defined elsewhere) is made (with success). >> This call (see here >> <http://leenissen.dk/fann/html/files/fann_train-h.html#fann_create_train>) >> initialises the struct and performs the allocation. >> >> The following lines, from 48 to 52, is where is am lost, due to my >> limited experience with wrapping C from Julia, (and with Julia). What I >> basically want to achieve is to create, for both the input and the output, >> a pointer to pointers pointing to the memory address of the relevant >> elements in X and y, which are user data, (sorry for the two many point*). >> In this way I do not have to make copies of the data, but just store some >> pointer. >> >> The second file example.jl demonstrates the issue. For some simple inputs >> and outputs, I first create the dataset (line 9) and then try to read the >> data that has been passed to the C struct. As explained in the gist, I am >> unable to read the same data that was written, and I am thus unable to >> train a network on that data. >> >> Can you please give me some advice on how to proceed further, I might >> just have taken the wrong way. >> I might have forgotten to say something here, so please ask further >> details. >> >> Cheers, >> >> Davide >> >> >> >> >
