Esempio n. 1
0
    void forward( ccube_p<real> const & f ) override
    {
        ZI_ASSERT(size(*f)==insize);
        auto r = pooling_filter(get_copy(*f),
                                [](real a, real b){ return a>b; },
                                filter_size,
                                vec3i::one);

        indices = sparse_implode_slow(*r.second,filter_size,outsize);
        out_nodes->forward(out_num,
                           sparse_implode_slow(*r.first,filter_size,outsize));
    }
Esempio n. 2
0
    void do_update( ccube_p<complex> const & g )
    {
        ZI_ASSERT(enabled_);

        auto dEdW_fft = *last_input * *g;
        auto dEdW = fftw_.backward(std::move(dEdW_fft));
        real norm = dEdW->num_elements();

        if ( fftw_.size() != fftw_.actual_size() )
        {
            dEdW = crop_left(*dEdW, fftw_.size());
        }

        flip(*dEdW);
        // TODO(zlateski): WTH was happening with sparse_implode before
        //                 when I had to use sparse_implode_slow
        //                 ony happened on my laptop
        dEdW = sparse_implode_slow(*dEdW, filter_stride, size(filter_.W()));
        *dEdW /= norm;

        filter_.update(*dEdW, patch_sz_);

#ifndef ZNN_DONT_CACHE_FFTS
        initialize();
#endif
    }
    void do_update( ccube_p<complex> const & g )
    {
        auto dEdW_fft = *last_input * *g;
        auto dEdW = fftw::backward(std::move(dEdW_fft), in_nodes->fsize());
        real norm = dEdW->num_elements();

        flip(*dEdW);
        // TODO(zlateski): WTH was happening with sparse_implode before
        //                 when I had to use sparse_implode_slow
        //                 ony happened on my laptop
        dEdW = sparse_implode_slow(*dEdW, filter_stride, size(filter_.W()));
        *dEdW /= norm;

        //flatten(*dEdW, repeat_);
        filter_.update(*dEdW, patch_sz_);
        flatten(filter_.W(), repeat_);

#ifndef ZNN_DONT_CACHE_FFTS
        initialize();
#endif
    }