Hmm, seems the above method has some drawbacks.
Just did some research, and found a way better method.
Try this:
add_filter( 'pre_option_generate_settings','tu_dynamic_container_type' );
function tu_dynamic_container_type( $options ) {
if ( is_front_page() ) {
$options[ 'content_layout_setting' ] = 'separate-containers';
}
return $options;
}