1、实用标准文案public class DrpcClient { public static void main(String[] args) throws Exception { int InputHideCount = 32; /* Input Hide输入数量 */ int HideOutCount = 10; /* Hide Bolt输出数量,等于是Out Bolt的输入数量 */ int OutCount = 4; /* Out输出数量,等于Real的数量 */ Topolog
2、yBuilder builder = new TopologyBuilder(); DRPCSpout drpcSpout = new DRPCSpout("BPTrain"); builder.setSpout("drpcSpout", drpcSpout, 1); builder.setBolt("hide", new HideBolt(), HideOutCount).allGrouping("drpcSpout"); // OutBolt的传参 必须等于 HideBolt的个数
3、 builder.setBolt("out", new OutBolt(HideOutCount), OutCount).allGrouping("hide"); // TrainBPFinsh的传参 必须等于 OutBolt的个数 builder.setBolt("finsh", new TrainBPFinsh(OutCount), 1).allGrouping("out"); builder.setBolt("return", new ReturnResults(), 1).allGrou
4、ping("finsh"); Config conf = new Config(); conf.setNumWorkers(Integer.parseInt(args[1])); StormSubmitter.submitTopology(args[0], conf, builder.createTopology()); String hideweight = getWeightStr(InputHideCount + 1, HideOutCount); // 隐藏层的权重 S
5、tring outweight = getWeightStr(HideOutCount + 1, OutCount);// 输出层的权重 DRPCClient client = new DRPCClient("mynode001", 3772); int[] ranInt = new int[1000]; for (int i = 0; i < ranInt.length; i++) { ranInt[i] = new java.util.Random().nextInt();
6、 } int Num = 0; System.out.println("开始训练"); for (int i = 0; i < 2000; i++) { double r = 0d; for (int j = 0; j < ranInt.length; j++) {// RandomNum MyRandom = new RandomNum(ranInt[j]);精彩文档实用标准文案 String i
7、nput = MyRandom.getInputDataStr(); String real = MyRandom.getRealDataStr(); String[] result = client.execute( "BPTrain", String.valueOf(Num) + "::" + input + "::" + real + "::" + hideweight + "::"