Example #1
0

## only use one video for now
# _video_ind = 0
# per_video_db = np.stack((datadb[_video_ind]['x'],datadb[_video_ind]['y'],datadb[_video_ind]['z']),axis=-1)
# per_video_db = per_video_db[:,per_video_db.shape[1]-per_video_db.shape[1]/fps*fps:,:] #cut head to make dividable by seconds
# per_video_db = np.reshape(per_video_db,(per_video_db.shape[0],per_video_db.shape[1]/fps,90))

## assign data ## only use one video for now
# encoder_input_data = per_video_db[:,100:110,:]
# temp = per_video_db[:,110:120,:].copy()
# temp1 = np.zeros_like(temp)
# temp1[:,1:,:] = temp[:,:-1,:].copy()
# temp1[:,0,:] = encoder_input_data[:,-1,:]

_video_db,_video_db_future,_video_db_future_input = get_data(datadb,pick_user=False)
total_num_samples = _video_db.shape[0]

if cfg.shuffle_data:
    #shuffle the whole dataset
    # index_shuf = get_shuffle_index(total_num_samples)
    index_shuf = pickle.load(open('index_shuf.p','rb'))
    _video_db = shuffle_data(index_shuf,_video_db)
    _video_db_future = shuffle_data(index_shuf,_video_db_future)
    _video_db_future_input = shuffle_data(index_shuf,_video_db_future_input)


#use last few as test
# num_testing_sample = int(0.15*total_num_samples)
num_testing_sample = 1
encoder_input_data = _video_db[:-num_testing_sample,:,:]
Example #2
0
    outputs = output_dense(decoder_states)
    all_outputs.append(expand_dim_layer(outputs))
    # this_inputs = outputs
    states = [state_h, state_c]

all_outputs = Lambda(lambda x: K.concatenate(x, axis=1))(all_outputs)

model = Model(inputs, all_outputs)
model.compile(optimizer='Adam', loss='mean_squared_error',metrics=['accuracy'])

#### ========================================data============================================================
video_data_train = pickle.load(open('./360video/data/shanghai_dataset_xyz_train.p','rb'),encoding='latin1')    
video_data_train = clip_xyz(video_data_train)
datadb = video_data_train.copy()
# assert cfg.data_chunk_stride=1
_video_db,_video_db_future,_video_db_future_input = util.get_data(datadb,pick_user=False,num_user=34)

if cfg.input_mean_var:
    input_data = util.get_gt_target_xyz(_video_db_future_input)
else:
    input_data = _video_db_future_input
target_data = util.get_gt_target_xyz(_video_db_future)

### ====================Training====================
tag = 'single_LSTM_keras_sep24'
model_checkpoint = ModelCheckpoint(tag+'{epoch:02d}-{val_loss:.4f}.h5', monitor='val_loss', save_best_only=True)
reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.2,
                                 patience=3, min_lr=1e-6)
stopping = EarlyStopping(monitor='val_loss', min_delta=0, patience=10, verbose=0, mode='auto')
model.fit(input_data, target_data,
          batch_size=batch_size,
Example #3
0
model.compile(optimizer='Adam', loss='mean_squared_error',metrics=['accuracy'])



#### ====================data====================
# video_data_train = pickle.load(open('./360video/data/shanghai_dataset_xyz_train.p','rb'),encoding='latin1')    
# datadb_train = clip_xyz(video_data_train)
# video_data_test = pickle.load(open('./360video/data/shanghai_dataset_xyz_test.p','rb'),encoding='latin1')    
# datadb_test = clip_xyz(video_data_test)
      
# mygenerator = generator_train2(datadb_train,phase='train')
# mygenerator_val = generator_train2(datadb_test,phase='val')

video_data_train = pickle.load(open('./360video/data/shanghai_dataset_xyz_train.p','rb'),encoding='latin1')    
video_data_train = clip_xyz(video_data_train)
_video_db,_video_db_future,_video_db_future_input = util.get_data(video_data_train,pick_user=False)
if cfg.input_mean_var:
    encoder_input_data = util.get_gt_target_xyz(_video_db)
else:
    encoder_input_data = _video_db
    # if use_embedding:
    #     # first convert encoder_inputs into integers
    #     encoder_input_data+=1
    #     step = 2./vocabulary_size
    #     encoder_input_data = np.int32(encoder_input_data//step)
decoder_target_data = util.get_gt_target_xyz(_video_db_future)
decoder_input_data = util.get_gt_target_xyz(_video_db_future_input)[:,0,:][:,np.newaxis,:]
if cfg.include_time_ind:
    time_ind_data = np.repeat(np.arange(max_decoder_seq_length).reshape(-1,1),decoder_input_data.shape[0],axis=-1).transpose((1,0))[:,:,np.newaxis]

### ====================Training====================