@@ -1102,7 +1102,18 @@ <h5 class="step-title">Schema of deployment</h5>
11021102 data [ "poisoned_node_percent" ] = document . getElementById ( "poisoned-node-percent" ) . value ,
11031103 data [ "poisoned_sample_percent" ] = document . getElementById ( "poisoned-sample-percent" ) . value ,
11041104 data [ "poisoned_noise_percent" ] = document . getElementById ( "poisoned-noise-percent" ) . value ,
1105- data [ "attack_params" ] = getAttackParams ( data [ "attacks" ] )
1105+ data [ "attack_params" ] = { }
1106+ data [ "attack_params" ] . poisoned_percent = document . getElementById ( "poisoned-sample-percent" ) . value ;
1107+ data [ "attack_params" ] . poisoned_ratio = document . getElementById ( "poisoned-noise-percent" ) . value ;
1108+ data [ "attack_params" ] . noise_type = document . getElementById ( "noise_type" ) . value ;
1109+ data [ "attack_params" ] . targeted = document . getElementById ( "targeted" ) . checked ;
1110+ data [ "attack_params" ] . target_label = document . getElementById ( "target_label" ) . value ;
1111+ data [ "attack_params" ] . target_changed_label = document . getElementById ( "target_changed_label" ) . value ;
1112+ data [ "attack_params" ] . strength = document . getElementById ( "strength" ) . value ;
1113+ data [ "attack_params" ] . layer_idx = document . getElementById ( "layer_idx" ) . value ;
1114+ data [ "attack_params" ] . delay = document . getElementById ( "delay" ) . value ;
1115+ data [ "attack_params" ] . round_start_attack = document . getElementById ( "start-attack" ) . value
1116+ data [ "attack_params" ] . round_stop_attack = document . getElementById ( "stop-attack" ) . value
11061117 // Step 13
11071118 data [ "with_reputation" ] = document . getElementById ( "with-reputation-btn" ) . checked ? true : false
11081119 data [ "is_dynamic_topology" ] = document . getElementById ( "dynamic-topology-btn" ) . checked ? true : false
@@ -1206,7 +1217,17 @@ <h5 class="step-title">Schema of deployment</h5>
12061217 document . getElementById ( "poisoned-node-percent" ) . value = data [ "poisoned_node_percent" ]
12071218 document . getElementById ( "poisoned-sample-percent" ) . value = data [ "poisoned_sample_percent" ]
12081219 document . getElementById ( "poisoned-noise-percent" ) . value = data [ "poisoned_noise_percent" ]
1209- setAttackParams ( data [ "attacks" ] , data . attack_params )
1220+ document . getElementById ( "poisoned-sample-percent" ) . value = data . attack_params . poisoned_percent ;
1221+ document . getElementById ( "poisoned-noise-percent" ) . value = data . attack_params . poisoned_ratio ;
1222+ document . getElementById ( "noise_type" ) . value = data . attack_params . noise_type ;
1223+ document . getElementById ( "targeted" ) . checked = data . attack_params . targeted ;
1224+ document . getElementById ( "target_label" ) . value = data . attack_params . target_label ;
1225+ document . getElementById ( "target_changed_label" ) . value = data . attack_params . target_changed_label ;
1226+ document . getElementById ( "strength" ) . value = data . attack_params . strength ;
1227+ document . getElementById ( "layer_idx" ) . value = data . attack_params . layer_idx ;
1228+ document . getElementById ( "delay" ) . value = data . attack_params . delay ;
1229+ document . getElementById ( "start-attack" ) . value = data . attack_params . round_start_attack
1230+ document . getElementById ( "stop-attack" ) . value = data . attack_params . round_stop_attack
12101231
12111232 if ( data [ "poisoned_node_percent" ] == 0 )
12121233 {
@@ -1253,82 +1274,9 @@ <h5 class="step-title">Schema of deployment</h5>
12531274 }
12541275 }
12551276 } catch ( error ) {
1256- console . error ( error ) ;
1277+ console . log ( error ) ;
12571278 }
12581279 }
1259-
1260- function getAttackParams ( attack ) {
1261- let attack_params = {
1262- noise_type : null ,
1263- targeted : null ,
1264- target_label : null ,
1265- target_changed_label : null ,
1266- strength : null ,
1267- layer_idx : null ,
1268- delay : null ,
1269- } ;
1270-
1271- if ( attack === "GLLNeuronInversionAttack" ) {
1272- // no parameters needed
1273- } else if ( attack === "NoiseInjectionAttack" ) {
1274- attack_params . strength = document . getElementById ( "strength" ) . value || null ;
1275- } else if ( attack === "SwappingWeightsAttack" ) {
1276- attack_params . layer_idx = document . getElementById ( "layer_idx" ) . value || null ;
1277- } else if ( attack === "DelayerAttack" ) {
1278- attack_params . delay = document . getElementById ( "delay" ) . value || null ;
1279- } else if ( [ "Label Flipping" , "Sample Poisoning" ] . includes ( attack ) ) {
1280- attack_params . poisoned_percent = document . getElementById ( "poisoned-sample-percent" ) . value || null ;
1281- attack_params . poisoned_ratio = document . getElementById ( "poisoned-noise-percent" ) . value || null ;
1282- attack_params . noise_type = document . getElementById ( "noise_type" ) . value || null ;
1283- attack_params . targeted = document . getElementById ( "targeted" ) . checked ? true : false ;
1284- attack_params . target_label = document . getElementById ( "target_label" ) . value || null ;
1285- attack_params . target_changed_label = document . getElementById ( "target_changed_label" ) . value || null ;
1286- } else if ( attack === "Model Poisoning" ) {
1287- attack_params . poisoned_ratio = document . getElementById ( "poisoned-noise-percent" ) . value || null ;
1288- attack_params . noise_type = document . getElementById ( "noise_type" ) . value || null ;
1289- }
1290- attack_params . round_start_attack = document . getElementById ( "start-attack" ) . value
1291- attack_params . round_stop_attack = document . getElementById ( "stop-attack" ) . value
1292-
1293- return attack_params ;
1294- }
1295-
1296- function setAttackParams ( attack , attack_params ) {
1297- const defaultParams = {
1298- noise_type : "Salt" ,
1299- targeted : false ,
1300- target_label : 0 ,
1301- target_changed_label : 1 ,
1302- strength : 1000 ,
1303- layer_idx : 0 ,
1304- delay : 0 ,
1305- poisoned_percent : 0 ,
1306- poisoned_ratio : 0 ,
1307- } ;
1308-
1309- if ( attack === "NoiseInjectionAttack" ) {
1310- document . getElementById ( "strength" ) . value = attack_params . strength ?? defaultParams . strength ;
1311- } else if ( attack === "SwappingWeightsAttack" ) {
1312- document . getElementById ( "layer_idx" ) . value = attack_params . layer_idx ?? defaultParams . layer_idx ;
1313- } else if ( attack === "DelayerAttack" ) {
1314- document . getElementById ( "delay" ) . value = attack_params . delay ?? defaultParams . delay ;
1315- } else if ( [ "Label Flipping" , "Sample Poisoning" ] . includes ( attack ) ) {
1316- document . getElementById ( "poisoned-sample-percent" ) . value = attack_params . poisoned_percent ?? defaultParams . poisoned_percent ;
1317- document . getElementById ( "poisoned-noise-percent" ) . value = attack_params . poisoned_ratio ?? defaultParams . poisoned_ratio ;
1318- document . getElementById ( "noise_type" ) . value = attack_params . noise_type ?? defaultParams . noise_type ;
1319- document . getElementById ( "targeted" ) . checked = attack_params . targeted ?? defaultParams . targeted ;
1320- document . getElementById ( "targeted" ) . dispatchEvent ( new Event ( 'change' ) ) ;
1321- document . getElementById ( "target_label" ) . value = attack_params . target_label ?? defaultParams . target_label ;
1322- document . getElementById ( "target_changed_label" ) . value = attack_params . target_changed_label ?? defaultParams . target_changed_label ;
1323- } else if ( attack === "Model Poisoning" ) {
1324- document . getElementById ( "poisoned-noise-percent" ) . value = attack_params . poisoned_ratio ?? defaultParams . poisoned_ratio ;
1325- document . getElementById ( "noise_type" ) . value = attack_params . noise_type ?? defaultParams . noise_type ;
1326- }
1327- document . getElementById ( "start-attack" ) . value = attack_params . round_start_attack
1328- document . getElementById ( "stop-attack" ) . value = attack_params . round_stop_attack
1329-
1330- return attack_params ;
1331- }
13321280 </ script >
13331281
13341282 < script >
0 commit comments