<s> import logging <EOL> import numpy as np <EOL> import os <EOL> import pickle <EOL> from neon . backends import gen_backend <EOL> from neon . util . argparser import NeonArgparser , extract_valid_args <EOL> from neon . data import PASCALVOC <EOL> from neon . data . datasets import Dataset <EOL> logging . basicConfig ( level = <NUM_LIT:20> ) <EOL> logger = logging . getLogger ( ) <EOL> def test_pascalvoc ( backend_default , data ) : <EOL> url = '<STR_LIT>' <EOL> filename = '<STR_LIT>' <EOL> size = <NUM_LIT> <EOL> workdir , filepath = Dataset . _valid_path_append ( data , '<STR_LIT>' , filename ) <EOL> if not os . path . exists ( filepath ) : <EOL> Dataset . fetch_dataset ( url , filename , filepath , size ) <EOL> with open ( filepath , '<STR_LIT:rb>' ) as handle : <EOL> neon_data_ref = pickle . loads ( handle . read ( ) ) <EOL> n_mb = neon_data_ref [ '<STR_LIT>' ] <EOL> img_per_batch = neon_data_ref [ '<STR_LIT>' ] <EOL> rois_per_img = neon_data_ref [ '<STR_LIT>' ] <EOL> dataset = neon_data_ref [ '<STR_LIT>' ] <EOL> year = neon_data_ref [ '<STR_LIT>' ] <EOL> output_type = neon_data_ref [ '<STR_LIT>' ] <EOL> rois_random_sample = neon_data_ref [ '<STR_LIT>' ] <EOL> shuffle = neon_data_ref [ '<STR_LIT>' ] <EOL> train_set = PASCALVOC ( dataset , year , path = data , output_type = output_type , n_mb = n_mb , <EOL> img_per_batch = img_per_batch , rois_per_img = rois_per_img , <EOL> rois_random_sample = rois_random_sample , shuffle = shuffle ) <EOL> for mb_i , ( X_batch , y_batch ) in enumerate ( train_set ) : <EOL> image_neon = X_batch [ <NUM_LIT:0> ] . get ( ) <EOL> image_ref = neon_data_ref [ '<STR_LIT>' ] [ mb_i ] <EOL> rois_neon = X_batch [ <NUM_LIT:1> ] . get ( ) <EOL> rois_ref = neon_data_ref [ '<STR_LIT>' ] [ mb_i ] <EOL> label_neon = y_batch [ <NUM_LIT:0> ] . get ( ) <EOL> label_ref = neon_data_ref [ '<STR_LIT>' ] [ mb_i ] <EOL> bbtarget_neon = y_batch [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . get ( ) <EOL> bbtarget_ref = neon_data_ref [ '<STR_LIT>' ] [ mb_i ] <EOL> mask_neon = y_batch [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] . get ( ) <EOL> mask_ref = neon_data_ref [ '<STR_LIT>' ] [ mb_i ] <EOL> assert np . allclose ( image_neon , image_ref , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) <EOL> assert np . allclose ( rois_neon , rois_ref , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) <EOL> assert np . allclose ( label_neon , label_ref , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) <EOL> assert np . allclose ( bbtarget_neon , bbtarget_ref , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) <EOL> assert np . allclose ( mask_neon , mask_ref , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> parser = NeonArgparser ( __doc__ ) <EOL> args = parser . parse_args ( gen_be = False ) <EOL> args . batch_size = <NUM_LIT> <EOL> be = gen_backend ( ** extract_valid_args ( args , gen_backend ) ) <EOL> test_pascalvoc ( be , args . data_dir ) </s>
