diff --git a/ppgan/models/cycle_gan_model.py b/ppgan/models/cycle_gan_model.py index eddddde5e03f8ee3624adaaaa94bf5f50f74aac3..fd7204f5ed8a60114dfe74354b1c032b7c7504c7 100644 --- a/ppgan/models/cycle_gan_model.py +++ b/ppgan/models/cycle_gan_model.py @@ -122,6 +122,7 @@ class CycleGANModel(BaseModel): def forward(self): """Run forward pass; called by both functions and .""" if hasattr(self, 'real_A'): + self.real_A.stop_gradient = False self.fake_B = self.nets['netG_A'](self.real_A) # G_A(A) self.rec_A = self.nets['netG_B'](self.fake_B) # G_B(G_A(A)) @@ -229,14 +230,13 @@ class CycleGANModel(BaseModel): # forward # compute fake images and reconstruction images. self.forward() - # G_A and G_B - # Ds require no gradients when optimizing Gs - self.set_requires_grad([self.nets['netD_A'], self.nets['netD_B']], - False) # set G_A and G_B's gradients to zero optimizers['optimG'].clear_grad() # calculate gradients for G_A and G_B self.backward_G() + # G_A and G_B + # Ds require no gradients when optimizing Gs + self.set_requires_grad([self.nets['netD_A'], self.nets['netD_B']], False) # update G_A and G_B's weights self.optimizers['optimG'].step() # D_A and D_B diff --git a/test_tipc/benchmark_train.sh b/test_tipc/benchmark_train.sh index 0741984f326c2fa20ea068a3decddaea067c6387..9422ca0dcfeb84fc42534c371cfc8c65f80ee952 100644 --- a/test_tipc/benchmark_train.sh +++ b/test_tipc/benchmark_train.sh @@ -73,7 +73,7 @@ REST_ARGS=$4 to_static="" # parse "to_static" options and modify trainer into "to_static_trainer" if [ $REST_ARGS = "to_static" ] || [ $PARAMS = "to_static" ] ;then - to_static="d2sT" + to_static="d2sT_" sed -i 's/trainer:norm_train/trainer:to_static_train/g' $FILENAME # clear PARAM contents if [ $PARAMS = "to_static" ] ;then @@ -175,7 +175,7 @@ for batch_size in ${batch_size_list[*]}; do if [ ${#gpu_id} -le 1 ];then log_path="$SAVE_LOG/profiling_log" mkdir -p $log_path - log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}_profiling" + log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}profiling" func_sed_params "$FILENAME" "${line_gpuid}" "0" # sed used gpu_id # set profile_option params tmp=`sed -i "${line_profile}s/.*/${profile_option}/" "${FILENAME}"` @@ -191,8 +191,8 @@ for batch_size in ${batch_size_list[*]}; do speed_log_path="$SAVE_LOG/index" mkdir -p $log_path mkdir -p $speed_log_path - log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}_log" - speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}_speed" + log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}log" + speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}speed" func_sed_params "$FILENAME" "${line_profile}" "null" # sed profile_id as null cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} benchmark_train > ${log_path}/${log_name} 2>&1 " echo $cmd @@ -226,8 +226,8 @@ for batch_size in ${batch_size_list[*]}; do speed_log_path="$SAVE_LOG/index" mkdir -p $log_path mkdir -p $speed_log_path - log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}_log" - speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}_speed" + log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}log" + speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}speed" func_sed_params "$FILENAME" "${line_gpuid}" "$gpu_id" # sed used gpu_id func_sed_params "$FILENAME" "${line_profile}" "null" # sed --profile_option as null cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} benchmark_train > ${log_path}/${log_name} 2>&1 "