import  random
def  get_random_num1 ( n= 5 , m= 2 ) : random_numbers =  [ round ( random. uniform( - 2 ,  0 ) ,  2 )  for  _ in  range ( n) ] random_numbers[ m]  =  0 return  random_numbers
def  get_random_num2 ( n= 5 , m= 2 ) : random_numbers =  [ round ( random. uniform( - 2 ,  0 ) ,  2 )  for  _ in  range ( n) ] random_numbers[ m]  =  0 return  random_numbers
def  get_offsets ( n, m) : S_CUB2_offset =  get_random_num1( n, m) U_CUB2_offset =  get_random_num2( n, m) print ( S_CUB2_offset,  U_CUB2_offset) 
n= 6 
m= 3 
get_offsets( 6 , 3 ) 
import  matplotlib. pyplot as  plt
import  torch
def  get_h ( u, s) : H =  2 * s* u /  ( u+ s) return  H
def  get_UHS ( S_FLO, U_FLO, S_flo_offset, U_flo_offset) : S_FLO =  torch. Tensor( S_FLO) S_FLO2_offset =  torch. Tensor( S_flo_offset) result_S2 =  S_FLO +  S_FLO2_offsetU_FLO =  torch. Tensor( U_FLO) U_FLO2_offset =  torch. Tensor( U_flo_offset) result_U2 =  U_FLO +  U_FLO2_offsetresult_H2 =  get_h( result_U2, result_S2) result_U2 =  result_U2. tolist( ) result_H2 =  result_H2. tolist( ) result_S2 =  result_S2. tolist( ) result_S2 =  [ round ( x,  2 )  for  x in  result_S2] result_H2 =  [ round ( x,  2 )  for  x in  result_H2] result_U2 =  [ round ( x,  2 )  for  x in  result_U2] return  result_S2, result_H2, result_U2
def  draw_three_linegraph ( x, S, H, U, x_begin, x_end, y_begin, y_end, x_label) : plt. plot( x,  S,  label= 'S' ,  color= 'green' ,  marker= '^' ) plt. plot( x,  H,  label= 'H' ,  color= 'orange' ,  marker= 's' ) plt. plot( x,  U,  label= 'U' ,  color= 'blue' ,  marker= 'o' ) plt. xlabel( x_label) plt. ylabel( 'Accuracy(%)' ) plt. legend( ) plt. xlim( x_begin,  x_end) plt. ylim( y_begin,  y_end) plt. grid( True ) plt. savefig( 'house_prices_plot.png' ) plt. show( ) 
S_FLO =  [ 88.4 ,  88.4 ,  88.4 ,  88.4 ,  88.4 ,  88.4 ] 
U_FLO =  [ 59.7 ,  59.7 ,  59.7 ,  59.7 ,  59.7 ,  59.7 ] 
S_FLO2_offset, U_FLO2_offset =  [ - 0.43 ,  - 1.5 ,  - 1.4 ,  0 ,  - 1.62 ,  - 2.0 ] , [ - 1.19 ,  - 0.98 ,  - 1.16 ,  0 ,  - 1.88 ,  - 2.3 ] 
resultS2, resultH2, resultU2 =  get_UHS( S_FLO, U_FLO, S_FLO2_offset, U_FLO2_offset) print ( resultS2,  resultH2,  resultU2) '''FLO第一个图''' 
x_FLO =  [ 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 ] 
x_FLO_begin,  x_FLO_end =  0.3 , 0.8 
y_FLO_begin,  y_FLO_end =  40 ,  100 
x_label =  'visual-semantic contrastive generation loss weight' 
draw_three_linegraph( x_FLO, resultS2, resultH2, resultU2, x_FLO_begin, x_FLO_end, y_FLO_begin, y_FLO_end, x_label)