├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── README.md ├── hs_err_pid10796.log ├── pom.xml ├── resources ├── linear_data_eval.csv ├── linear_data_train.csv └── log4j.properties ├── src ├── main │ └── java │ │ └── org │ │ └── aztec │ │ └── dl4j │ │ └── common │ │ ├── AritificialNerualNetworkFactory.java │ │ ├── ArtificialNeuralNetwork.java │ │ ├── ArtificialNeuralNetworkException.java │ │ ├── CustomerizedNetwork.java │ │ ├── DataConvertor.java │ │ ├── LayerConfiguration.java │ │ ├── LayerConfigurationFactory.java │ │ ├── NetworkConfiguration.java │ │ ├── impl │ │ ├── conf │ │ │ ├── AutomaticNetwokConfiguration.java │ │ │ ├── BaseLayerConfiguration.java │ │ │ ├── BaseNetworkConfiguration.java │ │ │ ├── NormalizationConfiguration.java │ │ │ └── SimpleNetworkConfiguration.java │ │ ├── data │ │ │ ├── CSVDataFileInfo.java │ │ │ ├── CSVDataSource.java │ │ │ ├── CSVFileConfig.java │ │ │ ├── CSVFileReader.java │ │ │ ├── NetworkInput.java │ │ │ ├── NewsIterator.java │ │ │ ├── PrepareWordVector.java │ │ │ ├── SimpleTensorIterator.java │ │ │ ├── ThreadGroupOptimizationDataSource.java │ │ │ ├── TrainNews.java │ │ │ └── UTF8TextConverter.java │ │ └── network │ │ │ ├── AutomaticBPNetwork.java │ │ │ ├── BaseNetwork.java │ │ │ └── SimpleBPNN.java │ │ ├── model │ │ └── ball │ │ │ ├── BallTrainNetwork.java │ │ │ └── BallTrainningUtils.java │ │ └── utils │ │ ├── NormalizeUtils.java │ │ ├── StringUtils.java │ │ └── TrainningUtils.java └── test │ └── java │ └── org │ └── aztec │ └── dl_common │ ├── App.java │ ├── BP_NetworkTest.java │ └── DirectHeapComparator.java └── test ├── arbiter ├── 0 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 1 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 2 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 3 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 4 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 5 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 6 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 7 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 8 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 9 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 10 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 11 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 12 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 13 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 14 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 15 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 16 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 17 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 18 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 19 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 20 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 21 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 22 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 23 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 24 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 25 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 26 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 27 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 28 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 29 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 30 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 31 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 32 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 33 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 34 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 35 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 36 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 37 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 38 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 39 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 40 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── 41 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt └── 42 │ ├── model.bin │ ├── numEpochs.txt │ └── score.txt ├── ball ├── ball_bet_match_result.csv ├── ball_bet_roll_data.csv └── bp_save.dat ├── csv ├── test_classfy_1.csv └── test_classfy_2.csv └── rnn ├── Cantonese.txt ├── CantoneseVector.txt ├── NewsWordVector.txt ├── RawText1.txt ├── RawText2.txt └── dialect ├── categories.txt ├── test ├── 0.txt └── 1.txt └── train ├── 0.txt └── 1.txt /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | dl-common 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding//src/test/java/org/aztec/dl_common/BP_NetworkTest.java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 13 | org.eclipse.jdt.core.compiler.source=1.8 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dl4j_common 2 | 深度学习框架deeplearning4j的封装框架。对BP网络,卷积网(CNN),递归神经网络(RNN)的使用和训练进行了简化,降低了初学者学习使用的难度。 3 | 4 | 下面是一个BP网络训练的示例 5 | 6 | try { 7 | //输入的特征数 8 | int inputNum = 5; 9 | //CSV文件中标签数据对应的位置 10 | int labelIndex = 0; 11 | //标签(分类)数 12 | int labelNum = 5; 13 | //批次大小 14 | int batchSize = 50; 15 | //读取csv文件得到训练集 16 | DataSetIterator trainIter = TrainningUtils.csvToDataSet(new CSVDataFileInfo(trainFile, batchSize, labelIndex, labelNum)); 17 | //读取csv文件得到测试集 18 | DataSetIterator testIter = TrainningUtils.csvToDataSet(new CSVDataFileInfo(trainFile, batchSize, labelIndex, labelNum)); 19 | //创建一个简单的BP网络配置 20 | NetworkConfiguration snc = new SimpleNetworkConfiguration(inputNum, labelNum); 21 | //设置隐层神经元个数 22 | snc.setNeuronNums(new int[] {1295}); 23 | //设置网络参数 24 | snc.setLayerNum(3); 25 | //snc.setBias(0.201); 26 | //设置学习率 27 | snc.setLearningRatio(0.5); 28 | //设置每层偏置 29 | snc.setBiases(new double[] {0.08,0.088,1}); 30 | //设置冲量 31 | snc.setMomentum(0.001); 32 | //设置训练世代 33 | snc.setNumEpochs(150); 34 | //通过网络配置获取对应的自动封装好的网络模型 35 | ArtificialNeuralNetwork bpnn = AritificialNerualNetworkFactory.getInstance(snc); 36 | //构建网络 37 | bpnn.buildNetwork(snc); 38 | //训练网络 39 | bpnn.train(trainIter, snc.getNumEpochs(),false); 40 | //验证网络 41 | bpnn.validate(testIter, labelNum,false); 42 | } catch (Exception e) { 43 | // TODO Auto-generated catch block 44 | e.printStackTrace(); 45 | } 46 | 47 | 48 | 框架封装了大量实用的网络模型,并配有相关易学易懂的demo,省去了学习dl4j api的功夫,可以集中精力于模型调优中,非常适合初学者学习使用。欢迎各路大神批评指正。 49 | -------------------------------------------------------------------------------- /hs_err_pid10796.log: -------------------------------------------------------------------------------- 1 | # 2 | # A fatal error has been detected by the Java Runtime Environment: 3 | # 4 | # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005e9e73ff, pid=10796, tid=0x0000000000001e44 5 | # 6 | # JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01) 7 | # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode windows-amd64 compressed oops) 8 | # Problematic frame: 9 | # V [jvm.dll+0x1e73ff] 10 | # 11 | # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows 12 | # 13 | # If you would like to submit a bug report, please visit: 14 | # http://bugreport.java.com/bugreport/crash.jsp 15 | # 16 | 17 | --------------- T H R E A D --------------- 18 | 19 | Current thread (0x0000000002b7e000): JavaThread "main" [_thread_in_vm, id=7748, stack(0x0000000002e80000,0x0000000002f80000)] 20 | 21 | siginfo: ExceptionCode=0xc0000005, reading address 0x0000000026f62a00 22 | 23 | Registers: 24 | RAX=0x0000000002b7e000, RBX=0x0000000002b7e000, RCX=0x0000000000000022, RDX=0x0000000002f7e228 25 | RSP=0x0000000002f7e140, RBP=0x0000000002f7e1f8, RSI=0x0000000027f1fb4b, RDI=0x0000000026f62a00 26 | R8 =0x0000000026f62a00, R9 =0x0000000002ca83f0, R10=0x0000000002fa0fe0, R11=0x000000005ea2bc50 27 | R12=0x0000000000000000, R13=0x0000000016d7b660, R14=0x0000000002f7e228, R15=0x0000000002b7e000 28 | RIP=0x000000005e9e73ff, EFLAGS=0x0000000000010246 29 | 30 | Top of Stack: (sp=0x0000000002f7e140) 31 | 0x0000000002f7e140: 0000000002f7e1f8 0000000002f7e1b8 32 | 0x0000000002f7e150: 0000000002f7e1b8 0000000002fa0b91 33 | 0x0000000002f7e160: 0000000000000000 0000000000000000 34 | 0x0000000002f7e170: 0000000002f883fd 0000000002fa100c 35 | 0x0000000002f7e180: 0000000016d7b660 0000000027f1fb4b 36 | 0x0000000002f7e190: 0000000002b7e000 0000000016d7b660 37 | 0x0000000002f7e1a0: 0000000002f883fd 0000000000000000 38 | 0x0000000002f7e1b0: 0000000002fa0b91 0000000002f7e1b8 39 | 0x0000000002f7e1c0: 0000000016d7b660 0000000002f7e228 40 | 0x0000000002f7e1d0: 0000000016da7e88 0000000000000000 41 | 0x0000000002f7e1e0: 0000000016d7b660 0000000000000000 42 | 0x0000000002f7e1f0: 0000000002f7e218 0000000002f7e270 43 | 0x0000000002f7e200: 0000000002f87fe0 0000000000000000 44 | 0x0000000002f7e210: 0000000002f971b9 0000000026f62a00 45 | 0x0000000002f7e220: 0000000002f7e278 0000000088a06a78 46 | 0x0000000002f7e230: 0000000002f7e230 000000001b25b5b4 47 | 48 | Instructions: (pc=0x000000005e9e73ff) 49 | 0x000000005e9e73df: b8 05 00 c7 83 70 02 00 00 06 00 00 00 8b 0d 56 50 | 0x000000005e9e73ef: c4 5c 00 ff 15 f8 5f 3f 00 c6 80 94 02 00 00 01 51 | 0x000000005e9e73ff: f3 0f 10 37 c6 80 94 02 00 00 00 48 8b 7b 48 48 52 | 0x000000005e9e740f: 8b 47 10 48 8b 77 08 48 83 38 00 74 15 48 8b 57 53 | 54 | 55 | Register to memory mapping: 56 | 57 | RAX=0x0000000002b7e000 is a thread 58 | RBX=0x0000000002b7e000 is a thread 59 | RCX=0x0000000000000022 is an unknown value 60 | RDX=0x0000000002f7e228 is pointing into the stack for thread: 0x0000000002b7e000 61 | RSP=0x0000000002f7e140 is pointing into the stack for thread: 0x0000000002b7e000 62 | RBP=0x0000000002f7e1f8 is pointing into the stack for thread: 0x0000000002b7e000 63 | RSI=0x0000000027f1fb4b is an unknown value 64 | RDI=0x0000000026f62a00 is an unknown value 65 | R8 =0x0000000026f62a00 is an unknown value 66 | R9 =0x0000000002ca83f0 is an unknown value 67 | R10=0x0000000002fa0fe0 is at code_begin+1632 in an Interpreter codelet 68 | method entry point (kind = native) [0x0000000002fa0980, 0x0000000002fa19a0] 4128 bytes 69 | R11=0x000000005ea2bc50 is an unknown value 70 | R12=0x0000000000000000 is an unknown value 71 | R13={method} {0x0000000016d7b668} 'getFloat' '(J)F' in 'sun/misc/Unsafe' 72 | R14=0x0000000002f7e228 is pointing into the stack for thread: 0x0000000002b7e000 73 | R15=0x0000000002b7e000 is a thread 74 | 75 | 76 | Stack: [0x0000000002e80000,0x0000000002f80000], sp=0x0000000002f7e140, free space=1016k 77 | Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) 78 | V [jvm.dll+0x1e73ff] 79 | C 0x0000000002fa100c 80 | 81 | Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) 82 | j sun.misc.Unsafe.getFloat(J)F+0 83 | j org.bytedeco.javacpp.indexer.UnsafeRaw.getFloat(J)F+4 84 | j org.bytedeco.javacpp.indexer.FloatRawIndexer.get(J)F+20 85 | j org.nd4j.linalg.api.buffer.BaseDataBuffer.getDouble(J)D+40 86 | j org.nd4j.linalg.api.ndarray.BaseNDArray.getDouble(J)D+78 87 | j org.nd4j.linalg.string.NDArrayStrings.vectorToString(Lorg/nd4j/linalg/api/ndarray/INDArray;Z)Ljava/lang/String;+84 88 | j org.nd4j.linalg.string.NDArrayStrings.format(Lorg/nd4j/linalg/api/ndarray/INDArray;IZ)Ljava/lang/String;+200 89 | j org.nd4j.linalg.string.NDArrayStrings.format(Lorg/nd4j/linalg/api/ndarray/INDArray;IZ)Ljava/lang/String;+498 90 | j org.nd4j.linalg.string.NDArrayStrings.format(Lorg/nd4j/linalg/api/ndarray/INDArray;Z)Ljava/lang/String;+152 91 | j org.nd4j.linalg.string.NDArrayStrings.format(Lorg/nd4j/linalg/api/ndarray/INDArray;)Ljava/lang/String;+3 92 | j org.nd4j.linalg.api.ndarray.BaseNDArray.toString()Ljava/lang/String;+21 93 | v ~StubRoutines::call_stub 94 | j org.aztec.dl_common.SimpleBPNN.train(Lorg/nd4j/linalg/dataset/api/iterator/DataSetIterator;I)V+5 95 | j org.aztec.dl_common.AppTest.testRead(ZILjava/io/File;)V+100 96 | j org.aztec.dl_common.AppTest.main([Ljava/lang/String;)V+13 97 | v ~StubRoutines::call_stub 98 | 99 | --------------- P R O C E S S --------------- 100 | 101 | Java Threads: ( => current thread ) 102 | 0x000000001a826800 JavaThread "NativeRandomDeallocator thread 0" daemon [_thread_blocked, id=10748, stack(0x0000000026020000,0x0000000026120000)] 103 | 0x000000001a780800 JavaThread "JavaCPP Deallocator" daemon [_thread_blocked, id=11280, stack(0x000000001ac30000,0x000000001ad30000)] 104 | 0x000000001a52c000 JavaThread "Workspace deallocator thread" daemon [_thread_blocked, id=9716, stack(0x000000001ab10000,0x000000001ac10000)] 105 | 0x0000000018c1c000 JavaThread "Service Thread" daemon [_thread_blocked, id=9488, stack(0x000000001a010000,0x000000001a110000)] 106 | 0x0000000018c0e000 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=12124, stack(0x0000000019e40000,0x0000000019f40000)] 107 | 0x0000000018c0d000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=11808, stack(0x0000000019be0000,0x0000000019ce0000)] 108 | 0x0000000018bb6800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=4656, stack(0x0000000019840000,0x0000000019940000)] 109 | 0x0000000018ba2800 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=11972, stack(0x0000000019a70000,0x0000000019b70000)] 110 | 0x0000000018b9f000 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=11464, stack(0x0000000019970000,0x0000000019a70000)] 111 | 0x0000000018b94800 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=10472, stack(0x0000000019740000,0x0000000019840000)] 112 | 0x00000000176ff000 JavaThread "Attach Listener" daemon [_thread_blocked, id=9536, stack(0x0000000019250000,0x0000000019350000)] 113 | 0x0000000018b8b800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=12120, stack(0x0000000019020000,0x0000000019120000)] 114 | 0x00000000176e0000 JavaThread "Finalizer" daemon [_thread_blocked, id=11592, stack(0x0000000018740000,0x0000000018840000)] 115 | 0x0000000017699000 JavaThread "Reference Handler" daemon [_thread_blocked, id=7976, stack(0x0000000018a70000,0x0000000018b70000)] 116 | =>0x0000000002b7e000 JavaThread "main" [_thread_in_vm, id=7748, stack(0x0000000002e80000,0x0000000002f80000)] 117 | 118 | Other Threads: 119 | 0x0000000017691000 VMThread [stack: 0x0000000018860000,0x0000000018960000] [id=7416] 120 | 0x0000000018c25800 WatcherThread [stack: 0x000000001a180000,0x000000001a280000] [id=10792] 121 | 122 | VM state:not at safepoint (normal execution) 123 | 124 | VM Mutex/Monitor currently owned by a thread: None 125 | 126 | Heap: 127 | PSYoungGen total 32768K, used 8781K [0x00000000d8380000, 0x00000000da900000, 0x0000000100000000) 128 | eden space 29184K, 19% used [0x00000000d8380000,0x00000000d8907fc8,0x00000000da000000) 129 | from space 3584K, 86% used [0x00000000da080000,0x00000000da38b580,0x00000000da400000) 130 | to space 4608K, 0% used [0x00000000da480000,0x00000000da480000,0x00000000da900000) 131 | ParOldGen total 81920K, used 1594K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 132 | object space 81920K, 1% used [0x0000000088a00000,0x0000000088b8e9f0,0x000000008da00000) 133 | Metaspace used 15140K, capacity 15338K, committed 15488K, reserved 1062912K 134 | class space used 2356K, capacity 2425K, committed 2432K, reserved 1048576K 135 | 136 | Card table byte_map: [0x0000000012340000,0x0000000012700000] byte_map_base: 0x0000000011efb000 137 | 138 | Marking Bits: (ParMarkBitMap*) 0x000000005f01d850 139 | Begin Bits: [0x0000000012d90000, 0x0000000014b68000) 140 | End Bits: [0x0000000014b68000, 0x0000000016940000) 141 | 142 | Polling page: 0x0000000000130000 143 | 144 | CodeCache: size=245760Kb used=1235Kb max_used=1235Kb free=244524Kb 145 | bounds [0x0000000002f80000, 0x00000000031f0000, 0x0000000011f80000] 146 | total_blobs=546 nmethods=0 adapters=468 147 | compilation: enabled 148 | 149 | Compilation events (0 events): 150 | No events 151 | 152 | GC Heap History (10 events): 153 | Event: 29.426 GC heap before 154 | {Heap before GC invocations=3 (full 0): 155 | PSYoungGen total 35840K, used 33308K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000) 156 | eden space 30720K, 100% used [0x00000000d8380000,0x00000000da180000,0x00000000da180000) 157 | from space 5120K, 50% used [0x00000000da680000,0x00000000da9070e0,0x00000000dab80000) 158 | to space 5120K, 0% used [0x00000000da180000,0x00000000da180000,0x00000000da680000) 159 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 160 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 161 | Metaspace used 8457K, capacity 8852K, committed 9088K, reserved 1056768K 162 | class space used 1282K, capacity 1336K, committed 1408K, reserved 1048576K 163 | Event: 29.429 GC heap after 164 | Heap after GC invocations=3 (full 0): 165 | PSYoungGen total 35840K, used 2674K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000) 166 | eden space 30720K, 0% used [0x00000000d8380000,0x00000000d8380000,0x00000000da180000) 167 | from space 5120K, 52% used [0x00000000da180000,0x00000000da41c948,0x00000000da680000) 168 | to space 5120K, 0% used [0x00000000da680000,0x00000000da680000,0x00000000dab80000) 169 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 170 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 171 | Metaspace used 8457K, capacity 8852K, committed 9088K, reserved 1056768K 172 | class space used 1282K, capacity 1336K, committed 1408K, reserved 1048576K 173 | } 174 | Event: 37.800 GC heap before 175 | {Heap before GC invocations=4 (full 0): 176 | PSYoungGen total 35840K, used 33394K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000) 177 | eden space 30720K, 100% used [0x00000000d8380000,0x00000000da180000,0x00000000da180000) 178 | from space 5120K, 52% used [0x00000000da180000,0x00000000da41c948,0x00000000da680000) 179 | to space 5120K, 0% used [0x00000000da680000,0x00000000da680000,0x00000000dab80000) 180 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 181 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 182 | Metaspace used 9431K, capacity 9844K, committed 10112K, reserved 1058816K 183 | class space used 1577K, capacity 1624K, committed 1664K, reserved 1048576K 184 | Event: 37.803 GC heap after 185 | Heap after GC invocations=4 (full 0): 186 | PSYoungGen total 35840K, used 2786K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000) 187 | eden space 30720K, 0% used [0x00000000d8380000,0x00000000d8380000,0x00000000da180000) 188 | from space 5120K, 54% used [0x00000000da680000,0x00000000da938958,0x00000000dab80000) 189 | to space 5120K, 0% used [0x00000000da180000,0x00000000da180000,0x00000000da680000) 190 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 191 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 192 | Metaspace used 9431K, capacity 9844K, committed 10112K, reserved 1058816K 193 | class space used 1577K, capacity 1624K, committed 1664K, reserved 1048576K 194 | } 195 | Event: 46.051 GC heap before 196 | {Heap before GC invocations=5 (full 0): 197 | PSYoungGen total 35840K, used 33506K [0x00000000d8380000, 0x00000000dab80000, 0x0000000100000000) 198 | eden space 30720K, 100% used [0x00000000d8380000,0x00000000da180000,0x00000000da180000) 199 | from space 5120K, 54% used [0x00000000da680000,0x00000000da938958,0x00000000dab80000) 200 | to space 5120K, 0% used [0x00000000da180000,0x00000000da180000,0x00000000da680000) 201 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 202 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 203 | Metaspace used 10512K, capacity 10932K, committed 11264K, reserved 1058816K 204 | class space used 1873K, capacity 1944K, committed 2048K, reserved 1048576K 205 | Event: 46.053 GC heap after 206 | Heap after GC invocations=5 (full 0): 207 | PSYoungGen total 33280K, used 3042K [0x00000000d8380000, 0x00000000dab00000, 0x0000000100000000) 208 | eden space 30208K, 0% used [0x00000000d8380000,0x00000000d8380000,0x00000000da100000) 209 | from space 3072K, 99% used [0x00000000da180000,0x00000000da478938,0x00000000da480000) 210 | to space 5120K, 0% used [0x00000000da600000,0x00000000da600000,0x00000000dab00000) 211 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 212 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 213 | Metaspace used 10512K, capacity 10932K, committed 11264K, reserved 1058816K 214 | class space used 1873K, capacity 1944K, committed 2048K, reserved 1048576K 215 | } 216 | Event: 104.767 GC heap before 217 | {Heap before GC invocations=6 (full 0): 218 | PSYoungGen total 33280K, used 33250K [0x00000000d8380000, 0x00000000dab00000, 0x0000000100000000) 219 | eden space 30208K, 100% used [0x00000000d8380000,0x00000000da100000,0x00000000da100000) 220 | from space 3072K, 99% used [0x00000000da180000,0x00000000da478938,0x00000000da480000) 221 | to space 5120K, 0% used [0x00000000da600000,0x00000000da600000,0x00000000dab00000) 222 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 223 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 224 | Metaspace used 12521K, capacity 12682K, committed 12928K, reserved 1060864K 225 | class space used 2106K, capacity 2137K, committed 2176K, reserved 1048576K 226 | Event: 104.770 GC heap after 227 | Heap after GC invocations=6 (full 0): 228 | PSYoungGen total 34304K, used 3316K [0x00000000d8380000, 0x00000000daa80000, 0x0000000100000000) 229 | eden space 29696K, 0% used [0x00000000d8380000,0x00000000d8380000,0x00000000da080000) 230 | from space 4608K, 71% used [0x00000000da600000,0x00000000da93d2c0,0x00000000daa80000) 231 | to space 5120K, 0% used [0x00000000da080000,0x00000000da080000,0x00000000da580000) 232 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 233 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 234 | Metaspace used 12521K, capacity 12682K, committed 12928K, reserved 1060864K 235 | class space used 2106K, capacity 2137K, committed 2176K, reserved 1048576K 236 | } 237 | Event: 168.659 GC heap before 238 | {Heap before GC invocations=7 (full 0): 239 | PSYoungGen total 34304K, used 33012K [0x00000000d8380000, 0x00000000daa80000, 0x0000000100000000) 240 | eden space 29696K, 100% used [0x00000000d8380000,0x00000000da080000,0x00000000da080000) 241 | from space 4608K, 71% used [0x00000000da600000,0x00000000da93d2c0,0x00000000daa80000) 242 | to space 5120K, 0% used [0x00000000da080000,0x00000000da080000,0x00000000da580000) 243 | ParOldGen total 81920K, used 0K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 244 | object space 81920K, 0% used [0x0000000088a00000,0x0000000088a00000,0x000000008da00000) 245 | Metaspace used 14952K, capacity 15146K, committed 15232K, reserved 1062912K 246 | class space used 2346K, capacity 2425K, committed 2432K, reserved 1048576K 247 | Event: 168.662 GC heap after 248 | Heap after GC invocations=7 (full 0): 249 | PSYoungGen total 32768K, used 3117K [0x00000000d8380000, 0x00000000da900000, 0x0000000100000000) 250 | eden space 29184K, 0% used [0x00000000d8380000,0x00000000d8380000,0x00000000da000000) 251 | from space 3584K, 86% used [0x00000000da080000,0x00000000da38b580,0x00000000da400000) 252 | to space 4608K, 0% used [0x00000000da480000,0x00000000da480000,0x00000000da900000) 253 | ParOldGen total 81920K, used 1594K [0x0000000088a00000, 0x000000008da00000, 0x00000000d8380000) 254 | object space 81920K, 1% used [0x0000000088a00000,0x0000000088b8e9f0,0x000000008da00000) 255 | Metaspace used 14952K, capacity 15146K, committed 15232K, reserved 1062912K 256 | class space used 2346K, capacity 2425K, committed 2432K, reserved 1048576K 257 | } 258 | 259 | Deoptimization events (0 events): 260 | No events 261 | 262 | Internal exceptions (10 events): 263 | Event: 2.621 Thread 0x0000000002b7e000 Exception (0x00000000d87aba78) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 264 | Event: 2.650 Thread 0x0000000002b7e000 Exception (0x00000000d87b43f8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 265 | Event: 2.650 Thread 0x0000000002b7e000 Exception (0x00000000d87b4608) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 266 | Event: 3.567 Thread 0x0000000002b7e000 Exception (0x00000000d8a755c0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 267 | Event: 3.567 Thread 0x0000000002b7e000 Exception (0x00000000d8a757d0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 268 | Event: 3.587 Thread 0x0000000002b7e000 Exception (0x00000000d8a79440) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 269 | Event: 3.587 Thread 0x0000000002b7e000 Exception (0x00000000d8a79650) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jvm.cpp, line 1390] 270 | Event: 3.710 Thread 0x0000000002b7e000 Exception (0x00000000d8abfa30) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 199] 271 | Event: 50.301 Thread 0x0000000002b7e000 Exception (0x00000000d9113e48) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jni.cpp, line 709] 272 | Event: 51.291 Thread 0x0000000002b7e000 Exception (0x00000000d9345f90) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jni.cpp, line 709] 273 | 274 | Events (10 events): 275 | Event: 295.386 Executing VM operation: GetOrSetLocal 276 | Event: 295.386 Executing VM operation: GetOrSetLocal done 277 | Event: 296.876 Executing VM operation: GetOrSetLocal 278 | Event: 296.876 Executing VM operation: GetOrSetLocal done 279 | Event: 297.777 Executing VM operation: GetOrSetLocal 280 | Event: 297.777 Executing VM operation: GetOrSetLocal done 281 | Event: 301.586 Executing VM operation: GetOrSetLocal 282 | Event: 301.586 Executing VM operation: GetOrSetLocal done 283 | Event: 304.000 Executing VM operation: GetOrSetLocal 284 | Event: 304.000 Executing VM operation: GetOrSetLocal done 285 | 286 | 287 | Dynamic libraries: 288 | 0x000000013f8b0000 - 0x000000013f8e7000 C:\Program Files\Java\jre1.8.0_144\bin\javaw.exe 289 | 0x0000000077490000 - 0x000000007762f000 C:\Windows\SYSTEM32\ntdll.dll 290 | 0x0000000077230000 - 0x000000007734f000 C:\Windows\system32\kernel32.dll 291 | 0x000007fefd170000 - 0x000007fefd1da000 C:\Windows\system32\KERNELBASE.dll 292 | 0x000007fefd970000 - 0x000007fefda4b000 C:\Windows\system32\ADVAPI32.dll 293 | 0x000007feff3c0000 - 0x000007feff45f000 C:\Windows\system32\msvcrt.dll 294 | 0x000007fefe520000 - 0x000007fefe53f000 C:\Windows\SYSTEM32\sechost.dll 295 | 0x000007fefe110000 - 0x000007fefe23d000 C:\Windows\system32\RPCRT4.dll 296 | 0x0000000077130000 - 0x000000007722a000 C:\Windows\system32\USER32.dll 297 | 0x000007fefe390000 - 0x000007fefe3f7000 C:\Windows\system32\GDI32.dll 298 | 0x000007fefe400000 - 0x000007fefe40e000 C:\Windows\system32\LPK.dll 299 | 0x000007fefd8a0000 - 0x000007fefd96b000 C:\Windows\system32\USP10.dll 300 | 0x000007fefaf20000 - 0x000007fefb114000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757\COMCTL32.dll 301 | 0x000007fefe4a0000 - 0x000007fefe511000 C:\Windows\system32\SHLWAPI.dll 302 | 0x000007feff750000 - 0x000007feff77e000 C:\Windows\system32\IMM32.DLL 303 | 0x000007fefd260000 - 0x000007fefd369000 C:\Windows\system32\MSCTF.dll 304 | 0x000007fefcd40000 - 0x000007fefcd70000 C:\Windows\system32\nvinitx.dll 305 | 0x000007fefcd30000 - 0x000007fefcd3c000 C:\Windows\system32\VERSION.dll 306 | 0x0000000074620000 - 0x0000000074626000 C:\Program Files\NVIDIA Corporation\CoProcManager\detoured.dll 307 | 0x000007fefa3f0000 - 0x000007fefa428000 C:\Program Files\NVIDIA Corporation\CoProcManager\nvd3d9wrapx.dll 308 | 0x000007fefdeb0000 - 0x000007fefe087000 C:\Windows\system32\SETUPAPI.dll 309 | 0x000007fefd080000 - 0x000007fefd0b6000 C:\Windows\system32\CFGMGR32.dll 310 | 0x000007feff2e0000 - 0x000007feff3ba000 C:\Windows\system32\OLEAUT32.dll 311 | 0x000007fefd5a0000 - 0x000007fefd79d000 C:\Windows\system32\ole32.dll 312 | 0x000007fefd1e0000 - 0x000007fefd1fa000 C:\Windows\system32\DEVOBJ.dll 313 | 0x000007fefa3c0000 - 0x000007fefa3e4000 C:\Program Files\NVIDIA Corporation\CoProcManager\nvdxgiwrapx.dll 314 | 0x0000000180000000 - 0x000000018012e000 C:\Windows\LVUAAgentInstBaseRoot\system32\Vozokopot.dll 315 | 0x000007fefe550000 - 0x000007feff2db000 C:\Windows\system32\SHELL32.dll 316 | 0x000007fefceb0000 - 0x000007fefcece000 C:\Windows\system32\USERENV.dll 317 | 0x000007fefce10000 - 0x000007fefce1f000 C:\Windows\system32\profapi.dll 318 | 0x000007fefbf50000 - 0x000007fefbfb1000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathWeb.dll 319 | 0x000007fefbbb0000 - 0x000007fefbf4d000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathCore.dll 320 | 0x0000000074870000 - 0x000000007490a000 C:\Windows\LVUAAgentInstBaseRoot\system32\SteinwayMSVCRT.dll 321 | 0x00000000747a0000 - 0x0000000074870000 C:\Windows\LVUAAgentInstBaseRoot\system32\SteinwayMSVCSTL.dll 322 | 0x000007fefbb30000 - 0x000007fefbba1000 C:\Windows\system32\WINSPOOL.DRV 323 | 0x000007fefe2f0000 - 0x000007fefe387000 C:\Windows\system32\COMDLG32.dll 324 | 0x000007fefe240000 - 0x000007fefe28d000 C:\Windows\system32\WS2_32.dll 325 | 0x000007fefe540000 - 0x000007fefe548000 C:\Windows\system32\NSI.dll 326 | 0x000007fefbfd0000 - 0x000007fefbfe1000 C:\Windows\system32\WTSAPI32.dll 327 | 0x000007fefc3e0000 - 0x000007fefc43b000 C:\Windows\system32\Dnsapi.dll 328 | 0x000007fefba70000 - 0x000007fefba90000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathWWW.dll 329 | 0x000007fefba50000 - 0x000007fefba6e000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathFw.dll 330 | 0x000007fefb9f0000 - 0x000007fefba4f000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathNet.dll 331 | 0x000007fefb9b0000 - 0x000007fefb9ea000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathFile.dll 332 | 0x000007fefb980000 - 0x000007fefb9ab000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathPrint.dll 333 | 0x000007fefb970000 - 0x000007fefb977000 C:\Windows\system32\MSIMG32.dll 334 | 0x000007fefb950000 - 0x000007fefb970000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathProcess.dll 335 | 0x000007fefb930000 - 0x000007fefb945000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathBolo.dll 336 | 0x000007fefb910000 - 0x000007fefb92a000 C:\Windows\LVUAAgentInstBaseRoot\system32\MozartBreathProtect.dll 337 | 0x000000005f0a0000 - 0x000000005f172000 C:\Program Files\Java\jre1.8.0_144\bin\msvcr100.dll 338 | 0x000000005e800000 - 0x000000005f09d000 C:\Program Files\Java\jre1.8.0_144\bin\server\jvm.dll 339 | 0x000007fef32c0000 - 0x000007fef32c9000 C:\Windows\system32\WSOCK32.dll 340 | 0x000007fefce60000 - 0x000007fefce9b000 C:\Windows\system32\WINMM.dll 341 | 0x0000000077640000 - 0x0000000077647000 C:\Windows\system32\PSAPI.DLL 342 | 0x0000000062d10000 - 0x0000000062d1f000 C:\Program Files\Java\jre1.8.0_144\bin\verify.dll 343 | 0x000000005f8f0000 - 0x000000005f919000 C:\Program Files\Java\jre1.8.0_144\bin\java.dll 344 | 0x0000000054550000 - 0x0000000054585000 C:\Program Files\Java\jre1.8.0_144\bin\jdwp.dll 345 | 0x000000005b250000 - 0x000000005b258000 C:\Program Files\Java\jre1.8.0_144\bin\npt.dll 346 | 0x000007fefb450000 - 0x000007fefb470000 C:\Windows\system32\Wlanapi.dll 347 | 0x000007fefb440000 - 0x000007fefb447000 C:\Windows\system32\wlanutil.dll 348 | 0x000000005fb50000 - 0x000000005fb66000 C:\Program Files\Java\jre1.8.0_144\bin\zip.dll 349 | 0x0000000071040000 - 0x0000000071049000 C:\Program Files\Java\jre1.8.0_144\bin\dt_socket.dll 350 | 0x000007fef7390000 - 0x000007fef73bf000 C:\Program Files (x86)\Sangfor\SSL\ClientComponent3\SangforNspX64.dll 351 | 0x000007fefa060000 - 0x000007fefa075000 C:\Windows\system32\NLAapi.dll 352 | 0x000007fef7370000 - 0x000007fef7385000 C:\Windows\system32\napinsp.dll 353 | 0x000007fef7350000 - 0x000007fef7369000 C:\Windows\system32\pnrpnsp.dll 354 | 0x000007fefc560000 - 0x000007fefc5b5000 C:\Windows\System32\mswsock.dll 355 | 0x000007fef7340000 - 0x000007fef734b000 C:\Windows\System32\winrnr.dll 356 | 0x000007fef7330000 - 0x000007fef7340000 C:\Windows\system32\wshbth.dll 357 | 0x000007fef9b00000 - 0x000007fef9b27000 C:\Windows\system32\IPHLPAPI.DLL 358 | 0x000007fef9af0000 - 0x000007fef9afb000 C:\Windows\system32\WINNSI.DLL 359 | 0x000007fef8710000 - 0x000007fef8763000 C:\Windows\System32\fwpuclnt.dll 360 | 0x000007fef8050000 - 0x000007fef8058000 C:\Windows\system32\rasadhlp.dll 361 | 0x000007fefb540000 - 0x000007fefb6bb000 C:\Program Files (x86)\Sangfor\SSL\ClientComponent3\SangforTcpX64.dll 362 | 0x000007fefd200000 - 0x000007fefd23b000 C:\Windows\system32\WINTRUST.dll 363 | 0x000007fefced0000 - 0x000007fefd03d000 C:\Windows\system32\CRYPT32.dll 364 | 0x000007fefce00000 - 0x000007fefce0f000 C:\Windows\system32\MSASN1.dll 365 | 0x000007fefb530000 - 0x000007fefb537000 C:\Windows\System32\wshtcpip.dll 366 | 0x000000005f860000 - 0x000000005f87a000 C:\Program Files\Java\jre1.8.0_144\bin\net.dll 367 | 0x000007fefc550000 - 0x000007fefc557000 C:\Windows\System32\wship6.dll 368 | 0x000000005f880000 - 0x000000005f891000 C:\Program Files\Java\jre1.8.0_144\bin\nio.dll 369 | 0x0000000069480000 - 0x000000006a600000 C:\Users\10064513\.javacpp\cache\nd4j-native-1.0.0-beta2-windows-x86_64.jar\org\nd4j\nativeblas\windows-x86_64\libnd4jcpu.dll 370 | 0x0000000066880000 - 0x0000000066e95000 C:\Users\10064513\.javacpp\cache\nd4j-native-1.0.0-beta2-windows-x86_64.jar\org\nd4j\nativeblas\windows-x86_64\jnind4jcpu.dll 371 | 0x000007fedacf0000 - 0x000007fedaddf000 C:\Users\10064513\.javacpp\cache\bin\msvcr120.dll 372 | 0x000000006d7c0000 - 0x000000006fcae000 C:\Users\10064513\.javacpp\cache\openblas-0.3.0-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\libopenblas_nolapack.dll 373 | 0x0000000002cb0000 - 0x0000000002d0c000 C:\Users\10064513\.javacpp\cache\openblas-0.3.0-1.4.2-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\jniopenblas_nolapack.dll 374 | 0x000007fefc5c0000 - 0x000007fefc5d8000 C:\Windows\system32\CRYPTSP.dll 375 | 0x000007fefc2c0000 - 0x000007fefc307000 C:\Windows\system32\rsaenh.dll 376 | 0x000007fefcc60000 - 0x000007fefcc6f000 C:\Windows\system32\CRYPTBASE.dll 377 | 0x000007fef86e0000 - 0x000007fef86f8000 C:\Windows\system32\dhcpcsvc.DLL 378 | 0x000007fef86c0000 - 0x000007fef86d1000 C:\Windows\system32\dhcpcsvc6.DLL 379 | 0x000007fef7aa0000 - 0x000007fef7bc5000 C:\Windows\system32\dbghelp.dll 380 | 381 | VM Arguments: 382 | jvm_args: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:59395 -Dfile.encoding=UTF-8 383 | java_command: org.aztec.dl_common.AppTest 384 | java_class_path (initial): C:\Program Files\Java\jre1.8.0_144\lib\resources.jar;C:\Program Files\Java\jre1.8.0_144\lib\rt.jar;C:\Program Files\Java\jre1.8.0_144\lib\jsse.jar;C:\Program Files\Java\jre1.8.0_144\lib\jce.jar;C:\Program Files\Java\jre1.8.0_144\lib\charsets.jar;C:\Program Files\Java\jre1.8.0_144\lib\jfr.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\cldrdata.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\dnsns.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\jaccess.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\jfxrt.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\localedata.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\nashorn.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunec.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunmscapi.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\zipfs.jar;D:\liming\develop\workspaces\dl-common\target\test-classes;D:\liming\develop\workspaces\dl-common\target\classes;C:\Users\10064513\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearning4j-core\1.0.0-beta2\deeplearning4j-core-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearning4j-tsne\1.0.0-beta2\deeplearning4j-tsne-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\nearestneighbor-core\1.0.0-beta2\nearestneighbor-core-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearning4j-datasets\1.0.0-beta2\deeplearning4j-datasets-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearning4j-common\1.0.0-beta2\deeplearning4j-common-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearning4j-datavec-iterators\1.0.0-beta2\deeplearning4j-datavec-iterators-1.0.0-beta2.jar;C:\Users\10064513\.m2\repository\org\deeplearning4j\deeplearn 385 | Launcher Type: SUN_STANDARD 386 | 387 | Environment Variables: 388 | JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07 389 | PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\TortoiseSVN\bin;D:\installs\apache-maven-2.2.1\bin;C:\Program Files\Java\jdk1.7.0_07\bin;D:\installs\zookeeper-3.3.6\zookeeper-3.3.6\bin;D:\installs\tail;C:\Program Files\MySQL\MySQL Utilities 1.6\;D:\installs\nginx-1.13.5\nginx-1.13.5;D:\installs\tortoiseGit\bin;D:\installs\Git\cmd 390 | USERNAME=10064513 391 | OS=Windows_NT 392 | PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 78 Stepping 3, GenuineIntel 393 | 394 | 395 | 396 | --------------- S Y S T E M --------------- 397 | 398 | OS: Windows 7 , 64 bit Build 7601 (6.1.7601.24214) 399 | 400 | CPU:total 4 (initial active 4) (2 cores per cpu, 2 threads per core) family 6 model 78 stepping 3, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx 401 | 402 | Memory: 4k page, physical 7822340k(2198360k free), swap 15642780k(7607928k free) 403 | 404 | vm_info: Java HotSpot(TM) 64-Bit Server VM (25.144-b01) for windows-amd64 JRE (1.8.0_144-b01), built on Jul 21 2017 21:57:33 by "java_re" with MS VC++ 10.0 (VS2010) 405 | 406 | time: Mon Oct 29 15:55:49 2018 407 | elapsed time: 305 seconds (0d 0h 5m 5s) 408 | 409 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.aztec 6 | dl-common 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | dl-common 11 | http://maven.apache.org 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | junit 20 | junit 21 | 3.8.1 22 | test 23 | 24 | 25 | 26 | org.deeplearning4j 27 | deeplearning4j-core 28 | 1.0.0-beta2 29 | 30 | 31 | org.deeplearning4j 32 | deeplearning4j-nlp 33 | 1.0.0-beta2 34 | 35 | 36 | org.nd4j 37 | nd4j-api 38 | 1.0.0-beta2 39 | 40 | 41 | org.nd4j 42 | nd4j-native 43 | 1.0.0-beta2 44 | 45 | 46 | org.nd4j 47 | nd4j-common 48 | 1.0.0-beta2 49 | 50 | 51 | org.datavec 52 | datavec-api 53 | 1.0.0-beta2 54 | 55 | 56 | org.deeplearning4j 57 | arbiter-deeplearning4j 58 | 1.0.0-beta2 59 | 60 | 61 | mysql 62 | mysql-connector-java 63 | 5.1.47 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /resources/linear_data_eval.csv: -------------------------------------------------------------------------------- 1 | 0,0.147562141324833,0.243518270820358 2 | 0,0.179868989766322,0.0922537025547999 3 | 1,0.754244045840797,0.52387485552728 4 | 0,0.248663780798734,0.175587276306351 5 | 0,0.397217489998824,0.0342134948381493 6 | 0,0.45098160780959,0.0328858982745571 7 | 0,0.335532917252522,0.16654442982869 8 | 0,0.371372049777255,0.167201755443297 9 | 0,0.280985655458144,0.214982885821991 10 | 0,0.313304894476342,0.00521976760984659 11 | 1,0.638465839375771,0.59044662666132 12 | 0,0.431591142988843,0.0470830726734468 13 | 0,0.207774186228136,0.0819718701225306 14 | 1,0.74160948940248,0.48471276227826 15 | 1,0.953514363329195,0.639625829881579 16 | 1,0.642944532413742,0.561453314573865 17 | 0,0.226494744243105,0.054182457565834 18 | 0,0.303693007460946,0.0231174890601685 19 | 0,0.442909334900624,0.26458738107626 20 | 1,0.689641361293936,0.441606457994801 21 | 1,0.808516873219165,0.460988843699898 22 | 0,0.265847526966108,-0.0217612302359918 23 | 0,0.277512671350018,-0.0351946196596575 24 | 1,0.650996504600044,0.281211163745124 25 | 1,0.604564151274163,0.581607217589511 26 | 0,0.361767990760365,0.08894162662105 27 | 1,0.666911463766987,0.658382180098643 28 | 0,0.23063312840159,-0.018832997639963 29 | 0,0.137952214405966,0.11362939867057 30 | 1,0.736452219294899,0.491761590839456 31 | 1,0.59710827462338,0.550563581924152 32 | 1,0.602609504754365,0.4272558830412 33 | 0,0.259748077463861,0.0830864567718866 34 | 1,0.65936769953152,0.398195251750205 35 | 1,0.68433814756797,0.243306417023253 36 | 1,0.855013781033494,0.552123366487809 37 | 1,0.960752241879643,0.589326478652242 38 | 0,0.218532689151841,0.149970476606352 39 | 0,0.340460187615256,0.163897051668133 40 | 0,0.355834203480917,0.336747248250862 41 | 1,0.692211516077662,0.577457901954487 42 | 1,0.662154960387187,0.570323144740557 43 | 0,0.372511985939819,0.0857198602571986 44 | 0,0.22900535800054,0.0267345028505001 45 | 0,0.309531718124159,0.144331015797212 46 | 0,0.263227253895867,0.127925334758116 47 | 0,0.308466277418238,0.0910351363893737 48 | 0,0.0930774599145935,0.113987148810076 49 | 1,0.6229369231208,0.456717036684569 50 | 1,0.706148123157656,0.490803325682998 51 | 1,0.758732482141232,0.456626655986977 52 | 1,0.694577645162027,0.622832560922402 53 | 0,0.369820198735285,0.0550497386655174 54 | 0,0.239404252953096,0.132757785197318 55 | 0,0.218428111377801,-0.219178158477306 56 | 1,0.692946434725903,0.544563975400229 57 | 0,0.245371538967234,0.101855416754447 58 | 1,0.56913442403047,0.294387382973145 59 | 1,0.714809619410276,0.538163512680377 60 | 0,0.358067954360732,0.17044538896009 61 | 0,0.320547428963535,0.251711615665619 62 | 0,0.331588068345858,0.107835653776275 63 | 0,0.304030747179208,0.0547750174185641 64 | 0,0.321995718652107,0.00579217815345798 65 | 1,0.865360178690971,0.428046918332584 66 | 1,0.671798231854105,0.344725091990453 67 | 1,0.828788452478336,0.71100719973842 68 | 1,0.781619318840399,0.632570613805373 69 | 1,0.731475532721693,0.257914929544682 70 | 1,0.629915796829575,0.284014988011287 71 | 0,0.422354335685084,0.114636655496169 72 | 1,0.673380826362505,0.577899254008376 73 | 0,0.411902241550325,-0.0328305542767028 74 | 1,0.819974434826139,0.549032982583942 75 | 1,0.749879048884502,0.521106457290703 76 | 1,0.865129108041695,0.505063149340243 77 | 1,0.802865060766911,0.534926888417566 78 | 1,0.757857478161499,0.353704731938664 79 | 1,0.795630162325943,0.351825595995113 80 | 0,0.462310717991569,0.101365623468382 81 | 0,0.269750572403886,-0.149506765860705 82 | 1,0.832120799383439,0.579782802852318 83 | 0,0.389685944569249,0.163719794768627 84 | 0,0.300495737942904,0.0420527462802183 85 | 0,0.301934594176741,0.0839837366231943 86 | 0,0.150962586848513,0.233882915802165 87 | 0,0.25452948081291,0.0859799579364082 88 | 1,0.758924966011327,0.51452726603244 89 | 1,0.688094757573297,0.451071027859505 90 | 0,0.308508646709991,0.124020803218039 91 | 1,0.55488440319187,0.712912973753406 92 | 1,0.734968534679093,0.291312226056919 93 | 0,0.424844828588299,0.0185442193071348 94 | 0,0.307133843847762,-0.0280343474796379 95 | 0,0.398740975001251,-0.0767590748067974 96 | 0,0.273728056742917,0.251849536602207 97 | 1,0.740350011751019,0.531733530441795 98 | 0,0.286412335506547,0.0834310455481071 99 | 1,0.844565148785342,0.556675571552102 100 | 1,0.570621351148686,0.405651266329464 101 | 1,0.780228461639442,0.682045157407263 102 | 1,0.808610830575502,0.48055917875417 103 | 0,0.404736393317852,0.0534461559608683 104 | 0,0.0182219815354657,-0.0890842632482053 105 | 1,0.580213837410484,0.434088367477381 106 | 0,0.439028571589774,-0.00891622428961927 107 | 0,0.169013026906772,0.139040747231028 108 | 1,0.721813199806076,0.453310307451834 109 | 1,0.579448726121783,0.601098430630891 110 | 1,0.59757790717587,0.582346229610322 111 | 1,0.706844037534213,0.444478339486168 112 | 0,0.311812492223678,-0.0245609488864325 113 | 1,0.696270344001157,0.559918986782424 114 | 0,0.517693836106899,0.136882581439463 115 | 1,0.711330813645891,0.368148477498463 116 | 1,0.651106025565724,0.645855201514964 117 | 0,0.312846178583358,0.167410567066292 118 | 0,0.245212502207789,0.0788996016352575 119 | 0,0.281584872796863,0.16330117675989 120 | 0,0.224177537883604,0.198729749727135 121 | 0,0.21360730861153,0.0659637945032196 122 | 0,0.236451258508006,0.0652936599183583 123 | 1,0.769116120629594,0.529177074205597 124 | 0,0.221575998142235,0.130222505896903 125 | 1,0.624409461092592,0.379450781522128 126 | 1,0.547121964828769,0.273564135415305 127 | 0,0.17592618523832,0.160037295166501 128 | 1,0.736121699674151,0.506024281122913 129 | 0,0.425480843904003,-0.0479291016901599 130 | 1,0.618590118156231,0.562390207752306 131 | 0,0.534384693355842,-0.00458315713932619 132 | 0,0.470829423375905,0.0567177119203065 133 | 0,0.375738399369332,0.10675402978279 134 | 0,0.319635320093047,0.129350314422456 135 | 0,0.243349669666206,0.116546106571295 136 | 0,0.34357354135486,-0.00338666050798213 137 | 0,0.186259256050742,0.049140403307173 138 | 1,0.646103731473393,0.476865433197868 139 | 1,0.742216880358217,0.390083115275135 140 | 1,0.839287534868438,0.550027764170609 141 | 1,0.800012129202795,0.466861127031535 142 | 0,0.216202082309659,0.176368365536743 143 | 1,0.780494991593676,0.375525772107199 144 | 1,0.726960940964144,0.580849892908468 145 | 1,0.743612641049324,0.552738236722576 146 | 1,0.597827269636531,0.314015371971029 147 | 1,0.753161899049477,0.612163367781747 148 | 1,0.672106155440207,0.541402426363875 149 | 0,0.611648647701236,-0.176614445962288 150 | 1,0.643311341435752,0.53917536733336 151 | 1,0.652427513768223,0.386155037786121 152 | 0,0.301520618087258,0.00779725506341844 153 | 1,0.580917034140212,0.318993261238895 154 | 1,0.658638758875195,0.58533531721232 155 | 1,0.522655469981122,0.526482285184902 156 | 1,0.619107709006306,0.395568496047808 157 | 0,0.342854385955556,0.00779057938184129 158 | 1,0.86999733382526,0.574001573496694 159 | 0,0.318543715852861,0.114391118336483 160 | 0,0.228396072599371,0.0106065027681785 161 | 1,0.727737130943151,0.38382553707226 162 | 0,0.242654358004674,0.229605566380433 163 | 1,0.849147311410968,0.485542675609488 164 | 1,0.688785680721008,0.568723327471366 165 | 1,0.601072641696223,0.472949199587446 166 | 0,0.386597757697056,-0.0462553172550934 167 | 0,0.173427736038098,0.0661032211070728 168 | 0,0.212619485253217,0.226220588353548 169 | 1,0.676379387810006,0.478200807508695 170 | 1,0.814570220992963,0.343974473335934 171 | 0,0.385176265775491,0.0321607979792773 172 | 1,0.749057204428228,0.460541975098555 173 | 0,0.249098133601278,0.135190023877858 174 | 1,0.755616419656037,0.499437877798512 175 | 1,0.605289891647501,0.576382527441655 176 | 0,0.220124707599109,0.100802583684052 177 | 1,0.611660353946956,0.582417425243852 178 | 1,0.638657314638631,0.567476782208443 179 | 1,0.707364959529237,0.553460099560961 180 | 1,0.750636527933954,0.418064859633507 181 | 0,0.258629634330844,0.205122708778633 182 | 1,0.561659196951965,0.302892925040985 183 | 0,0.261830597304793,0.0675225213946725 184 | 1,0.614308570486587,0.6059587413353 185 | 0,0.414439463469767,0.00965425791140319 186 | 0,0.252322879548744,0.0506559735947343 187 | 0,0.290671271152809,0.00155405446676163 188 | 0,0.235453515294468,0.110972028714464 189 | 1,0.732335416418508,0.448978572463179 190 | 1,0.810313994896262,0.495563824762476 191 | 0,0.421663017868487,-0.0356477152171603 192 | 1,0.696456152042301,0.492043579296949 193 | 1,0.648005874898818,0.474735589412081 194 | 1,0.586856365928848,0.486846359431101 195 | 0,0.311153185052651,0.0667137376136715 196 | 0,0.238197827120521,0.329800929790695 197 | 0,0.152745736144961,-0.0169226770608605 198 | 0,0.383676691365755,-0.0613888293971788 199 | 1,0.58794957455425,0.759074050955085 200 | 0,0.298771398500675,0.181005648077388 -------------------------------------------------------------------------------- /resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | log4j.rootLogger=ERROR, Console 3 | log4j.logger.play=DEBUG 4 | log4j.appender.Console=org.apache.log4j.ConsoleAppender 5 | log4j.appender.Console.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %-5p ~ %m%n 7 | 8 | log4j.appender.org.springframework=DEBUG 9 | log4j.appender.org.nd4j=INFO 10 | log4j.appender.org.canova=INFO 11 | log4j.appender.org.datavec=INFO 12 | log4j.appender.org.deeplearning4j=INFO 13 | log4j.appender.opennlp.uima=OFF 14 | log4j.appender.org.apache.uima=OFF 15 | log4j.appender.org.cleartk=OFF 16 | 17 | log4j.logger.org.springframework=INFO 18 | log4j.logger.org.nd4j=INFO 19 | log4j.logger.org.canova=INFO 20 | log4j.logger.org.datavec=INFO 21 | log4j.logger.org.deeplearning4j=INFO 22 | log4j.logger.opennlp.uima.util=OFF 23 | log4j.logger.org.apache.uima=OFF 24 | log4j.logger.org.cleartk=OFF 25 | 26 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/AritificialNerualNetworkFactory.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | import java.util.List; 4 | 5 | import org.aztec.dl4j.common.impl.network.AutomaticBPNetwork; 6 | import org.aztec.dl4j.common.impl.network.SimpleBPNN; 7 | 8 | import com.clearspring.analytics.util.Lists; 9 | 10 | public class AritificialNerualNetworkFactory { 11 | 12 | public static final List customerNetworks = Lists.newArrayList(); 13 | 14 | public AritificialNerualNetworkFactory() { 15 | // TODO Auto-generated constructor stub 16 | } 17 | 18 | public static ArtificialNeuralNetwork build(NetworkConfiguration config) throws ArtificialNeuralNetworkException { 19 | 20 | if(config != null) { 21 | switch(config.getConfigType()) { 22 | case SIMPLE: 23 | SimpleBPNN bpnn = new SimpleBPNN(); 24 | bpnn.buildNetwork(config); 25 | return bpnn; 26 | case AUTO: 27 | ArtificialNeuralNetwork network = new AutomaticBPNetwork(); 28 | network.buildNetwork(config); 29 | return network; 30 | default : 31 | for(CustomerizedNetwork cNetwork : customerNetworks) { 32 | if(cNetwork.canBuild(config)) { 33 | cNetwork.buildNetwork(config); 34 | return cNetwork; 35 | } 36 | } 37 | break; 38 | } 39 | } 40 | return null; 41 | 42 | } 43 | 44 | public static void addCustomerizedNetwork(CustomerizedNetwork cNetwork) { 45 | 46 | customerNetworks.add(cNetwork); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/ArtificialNeuralNetwork.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.deeplearning4j.eval.Evaluation; 7 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 8 | 9 | public interface ArtificialNeuralNetwork { 10 | 11 | public void buildNetwork(NetworkConfiguration networkConfig) throws ArtificialNeuralNetworkException; 12 | public void train(DataSetIterator trainningDatas,int numEpochs,boolean normalized) throws ArtificialNeuralNetworkException; 13 | public double[] predict(double[] features)throws ArtificialNeuralNetworkException; 14 | public void save(File file) throws IOException; 15 | public void load(File file) throws IOException; 16 | public Evaluation validate(DataSetIterator dataSet,int outputNum,boolean normalized) throws ArtificialNeuralNetworkException; 17 | public String toJson(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/ArtificialNeuralNetworkException.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | public class ArtificialNeuralNetworkException extends Exception{ 4 | 5 | public static enum ErrorCode{ 6 | 7 | BIAS_CONFIG_ERROR("CONF_E_01"), 8 | ACTIVATION_CONFIG_ERROR("CONF_E_02"), 9 | WEIGHT_INIT_CONFIG_ERROR("CONF_E_03"), 10 | L1_REGULARIZATION_CONFIG_ERROR("CONF_E_04"), 11 | L2_REGULARIZATION_CONFIG_ERROR("CONF_E_05"), 12 | NETWORK_CONFIG_ERROR("CONF_E_06"), 13 | NETWORK_NOT_BUILD("NW_E_01"), 14 | IO_ERROR("IO_E_01"), 15 | CONVERT_ERROR("IO_E_02"), 16 | TRAIN_FAIL("NW_E_02"); 17 | 18 | 19 | private ErrorCode(String code) { 20 | this.code = code; 21 | } 22 | 23 | private String code; 24 | 25 | public String getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(String code) { 30 | this.code = code; 31 | } 32 | 33 | public static ErrorCode translate(String code) { 34 | 35 | for(ErrorCode errCode : ErrorCode.values()) { 36 | if(errCode.getCode().equals(code)) { 37 | return errCode; 38 | } 39 | } 40 | return null; 41 | } 42 | } 43 | 44 | /** 45 | * 46 | */ 47 | private static final long serialVersionUID = 8924274536363739897L; 48 | private ErrorCode errorCode; 49 | 50 | public ArtificialNeuralNetworkException(String msg,ErrorCode errorCode) { 51 | super(msg); 52 | this.errorCode = errorCode; 53 | } 54 | 55 | public ArtificialNeuralNetworkException(String msg,Throwable t,ErrorCode errorCode) { 56 | super(msg,t); 57 | this.errorCode = errorCode; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/CustomerizedNetwork.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | public interface CustomerizedNetwork extends ArtificialNeuralNetwork{ 4 | 5 | public boolean canBuild(NetworkConfiguration config) ; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/DataConvertor.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | public interface DataConvertor { 4 | 5 | public double convert(String text) throws ArtificialNeuralNetworkException; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/LayerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | import org.deeplearning4j.nn.weights.WeightInit; 4 | import org.nd4j.linalg.activations.Activation; 5 | import org.nd4j.linalg.lossfunctions.LossFunctions.LossFunction; 6 | 7 | public interface LayerConfiguration { 8 | 9 | public int getOutputNum(); 10 | public int getInputNum(); 11 | public Double getBias(); 12 | public Double getl1(); 13 | public Double getl2(); 14 | public Activation getActiavtion(); 15 | public LossFunction getLossFunction(); 16 | public WeightInit getWeightInit(); 17 | public LayerType getType(); 18 | 19 | public static enum LayerType{ 20 | DENSE,OUTPUT; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/LayerConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | public interface LayerConfigurationFactory { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/NetworkConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common; 2 | 3 | import java.util.List; 4 | 5 | import org.deeplearning4j.nn.weights.WeightInit; 6 | import org.nd4j.linalg.activations.Activation; 7 | import org.nd4j.linalg.lossfunctions.LossFunctions.LossFunction; 8 | 9 | public interface NetworkConfiguration { 10 | 11 | public T adapt(Class realClass); 12 | public int getRngSeed(); 13 | public int getNumEpochs(); 14 | public double getL1(); 15 | public double getL2(); 16 | public double getBias(); 17 | public double getLearningRatio(); 18 | public double getInput(); 19 | public double getOutput(); 20 | public List getLayers(); 21 | public void init() throws ArtificialNeuralNetworkException; 22 | public NetworkConfigurationType getConfigType(); 23 | public void setBiases(double[] biases); 24 | public void setLayerNum(int layNum); 25 | public void setActivations(Activation[] activations); 26 | public void setLossFunction(LossFunction lossFunction); 27 | public void setWeightInits(WeightInit[] weightInits); 28 | public void setNeuronNums(int[] neuronNums); 29 | public void setL1s(double[] l1s); 30 | public void setL2s(double[] l2s); 31 | 32 | public static enum NetworkConfigurationType{ 33 | SIMPLE,COMPLEX,AUTO; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/conf/AutomaticNetwokConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.conf; 2 | 3 | import java.io.File; 4 | import java.util.Properties; 5 | 6 | import org.aztec.dl4j.common.NetworkConfiguration; 7 | import org.aztec.dl4j.common.impl.data.ThreadGroupOptimizationDataSource; 8 | import org.deeplearning4j.arbiter.optimize.api.data.DataSource; 9 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 10 | 11 | public class AutomaticNetwokConfiguration extends BaseNetworkConfiguration implements NetworkConfiguration { 12 | 13 | private double[] ratioRanges = new double[] { 0.0001, 0.1 }; 14 | private double[] biasRanges = new double[] { 0.01, 0.1 }; 15 | private int[] hiddenLayerNeuronNumRanges = new int[] { 16, 256 }; 16 | private File workingDir; 17 | private Long timeout; 18 | private Integer maxCandidateNum; 19 | private DataSource dataSource; 20 | 21 | public AutomaticNetwokConfiguration(int inputNum, int outputNum, double[] ratioRanges, int[] neuronNumRanges, 22 | File workingDir, Long timeout, Integer maxCandidateNum, DataSource dataSource) { 23 | super(inputNum, outputNum); 24 | this.ratioRanges = ratioRanges; 25 | this.hiddenLayerNeuronNumRanges = neuronNumRanges; 26 | this.workingDir = workingDir; 27 | this.timeout = timeout; 28 | this.maxCandidateNum = maxCandidateNum; 29 | this.dataSource = dataSource; 30 | } 31 | 32 | public AutomaticNetwokConfiguration(int inputNum, int outputNum, double[] ratioRanges, int[] neuronNumRanges, 33 | File workingDir, Long timeout, Integer maxCandidateNum, DataSetIterator trainData, DataSetIterator testData, 34 | Properties properties) { 35 | super(inputNum, outputNum); 36 | this.ratioRanges = ratioRanges; 37 | this.hiddenLayerNeuronNumRanges = neuronNumRanges; 38 | this.workingDir = workingDir; 39 | this.timeout = timeout; 40 | this.maxCandidateNum = maxCandidateNum; 41 | } 42 | 43 | public DataSource getDataSource() { 44 | return dataSource; 45 | } 46 | 47 | public void setDataSource(ThreadGroupOptimizationDataSource dataSource) { 48 | this.dataSource = dataSource; 49 | } 50 | 51 | public double[] getRatioRanges() { 52 | return ratioRanges; 53 | } 54 | 55 | public void setRatioRanges(double[] ratioRanges) { 56 | this.ratioRanges = ratioRanges; 57 | } 58 | 59 | public int[] getHiddenLayerNeuronNumRanges() { 60 | return hiddenLayerNeuronNumRanges; 61 | } 62 | 63 | public void setHiddenLayerNeuronNumRanges(int[] hiddenLayerNeuronNumRanges) { 64 | this.hiddenLayerNeuronNumRanges = hiddenLayerNeuronNumRanges; 65 | } 66 | 67 | public File getWorkingDir() { 68 | return workingDir; 69 | } 70 | 71 | public void setWorkingDir(File workingDir) { 72 | this.workingDir = workingDir; 73 | } 74 | 75 | public Long getTimeout() { 76 | return timeout; 77 | } 78 | 79 | public void setTimeout(Long timeout) { 80 | this.timeout = timeout; 81 | } 82 | 83 | public Integer getMaxCandidateNum() { 84 | return maxCandidateNum; 85 | } 86 | 87 | public void setMaxCandidateNum(Integer maxCandidateNum) { 88 | this.maxCandidateNum = maxCandidateNum; 89 | } 90 | 91 | public NetworkConfigurationType getConfigType() { 92 | // TODO Auto-generated method stub 93 | return NetworkConfigurationType.AUTO; 94 | } 95 | 96 | public Properties getConfigProperties() { 97 | if (ThreadGroupOptimizationDataSource.class.isAssignableFrom(dataSource.getClass())) { 98 | return ((ThreadGroupOptimizationDataSource) dataSource).getConfigProperties(); 99 | } 100 | return null; 101 | } 102 | 103 | public double[] getBiasRanges() { 104 | return biasRanges; 105 | } 106 | 107 | public void setBiasRanges(double[] biasRanges) { 108 | this.biasRanges = biasRanges; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/conf/BaseLayerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.conf; 2 | 3 | import org.aztec.dl4j.common.LayerConfiguration; 4 | import org.deeplearning4j.nn.weights.WeightInit; 5 | import org.nd4j.linalg.activations.Activation; 6 | import org.nd4j.linalg.lossfunctions.LossFunctions.LossFunction; 7 | 8 | public class BaseLayerConfiguration implements LayerConfiguration { 9 | 10 | 11 | protected int inputNum = 10; 12 | protected int outputNum = 10; // number of output classes 13 | protected Double momentum = null; 14 | protected Double bias = null; 15 | protected Double l2 = null; 16 | protected Double l1 = null; 17 | protected Activation activation = Activation.RELU; 18 | protected LossFunction lossFunction = LossFunction.NEGATIVELOGLIKELIHOOD; 19 | protected WeightInit weightInit = WeightInit.XAVIER; 20 | protected LayerType type; 21 | 22 | public BaseLayerConfiguration(LayerType type,int input,int output) { 23 | this.type = type; 24 | this.inputNum = input; 25 | this.outputNum = output; 26 | } 27 | 28 | public BaseLayerConfiguration(LayerType type) { 29 | this.type = type; 30 | } 31 | 32 | public int getOutputNum() { 33 | // TODO Auto-generated method stub 34 | return outputNum; 35 | } 36 | 37 | public int getInputNum() { 38 | // TODO Auto-generated method stub 39 | return inputNum; 40 | } 41 | 42 | 43 | public Double getBias() { 44 | // TODO Auto-generated method stub 45 | return bias; 46 | } 47 | 48 | public Double getl1() { 49 | // TODO Auto-generated method stub 50 | return l1; 51 | } 52 | 53 | public Double getl2() { 54 | // TODO Auto-generated method stub 55 | return l2; 56 | } 57 | 58 | public Activation getActiavtion() { 59 | // TODO Auto-generated method stub 60 | return activation; 61 | } 62 | 63 | public LossFunction getLossFunction() { 64 | // TODO Auto-generated method stub 65 | return lossFunction; 66 | } 67 | 68 | public WeightInit getWeightInit() { 69 | // TODO Auto-generated method stub 70 | return weightInit; 71 | } 72 | 73 | public double getMomentum() { 74 | return momentum; 75 | } 76 | 77 | public void setMomentum(double momentum) { 78 | this.momentum = momentum; 79 | } 80 | 81 | public double getL2() { 82 | return l2; 83 | } 84 | 85 | public void setL2(double l2) { 86 | this.l2 = l2; 87 | } 88 | 89 | public double getL1() { 90 | return l1; 91 | } 92 | 93 | public void setL1(double l1) { 94 | this.l1 = l1; 95 | } 96 | 97 | public void setInputNum(int inputNum) { 98 | this.inputNum = inputNum; 99 | } 100 | 101 | public void setOutputNum(int outputNum) { 102 | this.outputNum = outputNum; 103 | } 104 | 105 | public void setBias(double bias) { 106 | this.bias = bias; 107 | } 108 | 109 | public Activation getActivation() { 110 | return activation; 111 | } 112 | 113 | public void setActivation(Activation activation) { 114 | this.activation = activation; 115 | } 116 | 117 | public void setLossFunction(LossFunction lossFunction) { 118 | this.lossFunction = lossFunction; 119 | } 120 | 121 | public LayerType getType() { 122 | // TODO Auto-generated method stub 123 | return type; 124 | } 125 | 126 | public void setWeightInit(WeightInit weightInit) { 127 | this.weightInit = weightInit; 128 | } 129 | 130 | public void setType(LayerType type) { 131 | this.type = type; 132 | } 133 | 134 | 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/conf/BaseNetworkConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.conf; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.commons.compress.utils.Lists; 6 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException; 7 | import org.aztec.dl4j.common.LayerConfiguration; 8 | import org.aztec.dl4j.common.NetworkConfiguration; 9 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException.ErrorCode; 10 | import org.aztec.dl4j.common.LayerConfiguration.LayerType; 11 | import org.deeplearning4j.nn.weights.WeightInit; 12 | import org.nd4j.linalg.activations.Activation; 13 | import org.nd4j.linalg.lossfunctions.LossFunctions.LossFunction; 14 | 15 | public abstract class BaseNetworkConfiguration implements NetworkConfiguration { 16 | 17 | protected double bias = 0.1; 18 | protected double learnningRatio = 0.006; 19 | protected double momentum = 0.001; 20 | protected int layerNum = 3; 21 | protected int batchSize = 50; // batch size for each epoch 22 | protected int rngSeed = 123; // random number seed for reproducibility 23 | protected int numEpochs = 150; // number of epochs to perform 24 | protected double l1 = 1e-4; 25 | protected double l2 = 1e-4; 26 | protected List layers; 27 | 28 | protected int inputNum; 29 | protected int outputNum; 30 | protected int defaultNeuronNum = 10; 31 | protected Activation defaultActivation = Activation.RELU; 32 | protected Activation defaultOutputActivation = Activation.SOFTMAX; 33 | protected WeightInit defaultWeightInit = WeightInit.XAVIER; 34 | protected Activation[] activations; 35 | protected WeightInit[] weightInits; 36 | protected LossFunction lossFunction = LossFunction.NEGATIVELOGLIKELIHOOD; 37 | protected double[] l1s; 38 | protected double[] l2s; 39 | protected int[] neruonNums; 40 | protected double[] biases; 41 | 42 | public BaseNetworkConfiguration(int inputNum, int outputNum) { 43 | super(); 44 | this.inputNum = inputNum; 45 | this.outputNum = outputNum; 46 | } 47 | 48 | public void init() throws ArtificialNeuralNetworkException { 49 | initActivations(); 50 | initl1s(); 51 | initl2s(); 52 | initNeuronNums(); 53 | initWeightInits(); 54 | initBiases(); 55 | this.layers = generateLayerConfigurations(); 56 | } 57 | 58 | protected void initl1s() throws ArtificialNeuralNetworkException { 59 | if (l1s == null) { 60 | l1s = new double[layerNum]; 61 | for (int i = 0; i < layerNum; i++) { 62 | l1s[i] = l1; 63 | } 64 | } else { 65 | if (l1s.length < layerNum) { 66 | throw new ArtificialNeuralNetworkException(" l1 data missing", 67 | ErrorCode.L1_REGULARIZATION_CONFIG_ERROR); 68 | } 69 | } 70 | } 71 | 72 | protected void initl2s() throws ArtificialNeuralNetworkException { 73 | if (l2s == null) { 74 | l2s = new double[layerNum]; 75 | for (int i = 0; i < layerNum; i++) { 76 | l2s[i] = l2; 77 | } 78 | } else { 79 | if (l2s.length < layerNum) { 80 | throw new ArtificialNeuralNetworkException(" l2 data missing", 81 | ErrorCode.L2_REGULARIZATION_CONFIG_ERROR); 82 | } 83 | } 84 | } 85 | 86 | protected void initBiases() throws ArtificialNeuralNetworkException { 87 | if (biases == null) { 88 | biases = new double[layerNum]; 89 | for (int i = 0; i < layerNum; i++) { 90 | biases[i] = bias; 91 | } 92 | } else { 93 | if (biases.length < layerNum) { 94 | throw new ArtificialNeuralNetworkException(" biase data missing", ErrorCode.BIAS_CONFIG_ERROR); 95 | } 96 | } 97 | } 98 | 99 | protected void initWeightInits() throws ArtificialNeuralNetworkException { 100 | if (weightInits == null) { 101 | weightInits = new WeightInit[layerNum]; 102 | for (int i = 0; i < layerNum; i++) { 103 | weightInits[i] = defaultWeightInit; 104 | } 105 | } else { 106 | if (weightInits.length < layerNum) { 107 | throw new ArtificialNeuralNetworkException("weight inits data missing", 108 | ErrorCode.ACTIVATION_CONFIG_ERROR); 109 | } 110 | } 111 | } 112 | 113 | protected void initActivations() throws ArtificialNeuralNetworkException { 114 | if (activations == null) { 115 | activations = new Activation[layerNum]; 116 | for (int i = 0; i < layerNum; i++) { 117 | if (i == layerNum - 1) { 118 | activations[i] = defaultOutputActivation; 119 | } else { 120 | activations[i] = defaultActivation; 121 | } 122 | } 123 | } else { 124 | if (activations.length < layerNum) { 125 | throw new ArtificialNeuralNetworkException("Activation data missing", 126 | ErrorCode.ACTIVATION_CONFIG_ERROR); 127 | } 128 | } 129 | } 130 | 131 | protected void initNeuronNums() throws ArtificialNeuralNetworkException { 132 | if (neruonNums == null) { 133 | 134 | if(layerNum > 1) { 135 | neruonNums = new int[layerNum - 1]; 136 | for (int i = 0; i < layerNum - 1; i++) { 137 | if (i == layerNum - 1) { 138 | neruonNums[i] = defaultNeuronNum; 139 | } 140 | } 141 | } 142 | } else { 143 | if (layerNum > 1 && neruonNums.length < layerNum - 1) { 144 | throw new ArtificialNeuralNetworkException("neruon data missing", 145 | ErrorCode.NETWORK_CONFIG_ERROR); 146 | } 147 | } 148 | } 149 | 150 | protected List generateLayerConfigurations() { 151 | List configs = Lists.newArrayList(); 152 | BaseLayerConfiguration lastLayerConfig = null; 153 | for (int i = 0; i < layerNum; i++) { 154 | 155 | BaseLayerConfiguration layer = new BaseLayerConfiguration( 156 | i != layerNum - 1 ? LayerType.DENSE : LayerType.OUTPUT, 157 | lastLayerConfig == null ? inputNum : lastLayerConfig.getOutputNum(), 158 | i != layerNum - 1 ? neruonNums[i] : outputNum); 159 | layer.setActivation(activations[i]); 160 | layer.setWeightInit(weightInits[i]); 161 | if (i == layerNum - 1) { 162 | layer.setLossFunction(lossFunction); 163 | } 164 | if (biases != null && biases.length >= layerNum + 2) { 165 | layer.setBias(biases[i + 1]); 166 | } else { 167 | layer.setBias(bias); 168 | } 169 | lastLayerConfig = layer; 170 | configs.add(layer); 171 | } 172 | return configs; 173 | } 174 | 175 | public List getLayers() { 176 | return layers; 177 | } 178 | 179 | public void setLayers(List layers) { 180 | this.layers = layers; 181 | } 182 | 183 | public int getBatchSize() { 184 | return batchSize; 185 | } 186 | 187 | public void setBatchSize(int batchSize) { 188 | this.batchSize = batchSize; 189 | } 190 | 191 | public int getRngSeed() { 192 | return rngSeed; 193 | } 194 | 195 | public void setRngSeed(int rngSeed) { 196 | this.rngSeed = rngSeed; 197 | } 198 | 199 | public int getNumEpochs() { 200 | return numEpochs; 201 | } 202 | 203 | public void setNumEpochs(int numEpochs) { 204 | this.numEpochs = numEpochs; 205 | } 206 | 207 | public int getLayerNum() { 208 | return layerNum; 209 | } 210 | 211 | public void setLayerNum(int layNum) { 212 | this.layerNum = layNum; 213 | } 214 | 215 | public double getLearningRatio() { 216 | return learnningRatio; 217 | } 218 | 219 | public void setLearningRatio(double learnRatio) { 220 | this.learnningRatio = learnRatio; 221 | } 222 | 223 | public double getMomentum() { 224 | return momentum; 225 | } 226 | 227 | public void setMomentum(double momentum) { 228 | this.momentum = momentum; 229 | } 230 | 231 | public double getBias() { 232 | return bias; 233 | } 234 | 235 | public void setBias(double bias) { 236 | this.bias = bias; 237 | } 238 | 239 | public T adapt(Class realClass) { 240 | if (realClass.isAssignableFrom(this.getClass())) { 241 | return (T) this; 242 | } 243 | return null; 244 | } 245 | 246 | public int[] getLayerNeuronNums() { 247 | // TODO Auto-generated method stub 248 | return null; 249 | } 250 | 251 | public double[] getl1s() { 252 | // TODO Auto-generated method stub 253 | return null; 254 | } 255 | 256 | public double[] getl2s() { 257 | // TODO Auto-generated method stub 258 | return null; 259 | } 260 | 261 | public double getL1() { 262 | return l1; 263 | } 264 | 265 | public void setL1(double l1) { 266 | this.l1 = l1; 267 | } 268 | 269 | public double getL2() { 270 | return l2; 271 | } 272 | 273 | public void setL2(double l2) { 274 | this.l2 = l2; 275 | } 276 | 277 | public double getInput() { 278 | // TODO Auto-generated method stub 279 | return inputNum; 280 | } 281 | 282 | public double getOutput() { 283 | // TODO Auto-generated method stub 284 | return outputNum; 285 | } 286 | 287 | public Activation[] getActivations() { 288 | return activations; 289 | } 290 | 291 | public void setActivations(Activation[] activations) { 292 | this.activations = activations; 293 | } 294 | 295 | public double[] getBiases() { 296 | return biases; 297 | } 298 | 299 | public void setBiases(double[] biases) { 300 | this.biases = biases; 301 | } 302 | 303 | public LossFunction getLossFunction() { 304 | return lossFunction; 305 | } 306 | 307 | public void setLossFunction(LossFunction lossFunction) { 308 | this.lossFunction = lossFunction; 309 | } 310 | 311 | public WeightInit[] getWeightInits() { 312 | return weightInits; 313 | } 314 | 315 | public void setWeightInits(WeightInit[] weightInits) { 316 | this.weightInits = weightInits; 317 | } 318 | 319 | public int getInputNum() { 320 | return inputNum; 321 | } 322 | 323 | public void setInputNum(int inputNum) { 324 | this.inputNum = inputNum; 325 | } 326 | 327 | public int getOutputNum() { 328 | return outputNum; 329 | } 330 | 331 | public void setOutputNum(int outputNum) { 332 | this.outputNum = outputNum; 333 | } 334 | 335 | public void setNeuronNums(int[] neuronNums) { 336 | this.neruonNums = neuronNums; 337 | } 338 | 339 | public double[] getL1s() { 340 | return l1s; 341 | } 342 | 343 | public void setL1s(double[] l1s) { 344 | this.l1s = l1s; 345 | } 346 | 347 | public double[] getL2s() { 348 | return l2s; 349 | } 350 | 351 | public void setL2s(double[] l2s) { 352 | this.l2s = l2s; 353 | } 354 | 355 | } 356 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/conf/NormalizationConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.conf; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.commons.compress.utils.Lists; 6 | 7 | public class NormalizationConfiguration { 8 | 9 | private List rawDatas; 10 | private double[] upperLimites; 11 | 12 | public NormalizationConfiguration() { 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | 17 | 18 | public NormalizationConfiguration(List rawDatas, double[] upperLimites) { 19 | super(); 20 | this.rawDatas = rawDatas; 21 | this.upperLimites = upperLimites; 22 | } 23 | 24 | public NormalizationConfiguration(double[][] rawDatas, double[] upperLimites) { 25 | super(); 26 | this.rawDatas = Lists.newArrayList(); 27 | for(int i = 0;i < rawDatas.length;i++) { 28 | this.rawDatas.add(rawDatas[i]); 29 | } 30 | this.upperLimites = upperLimites; 31 | } 32 | 33 | public List getRawDatas() { 34 | return rawDatas; 35 | } 36 | 37 | public void setRawDatas(List rawDatas) { 38 | this.rawDatas = rawDatas; 39 | } 40 | 41 | public double[] getUpperLimites() { 42 | return upperLimites; 43 | } 44 | 45 | public void setUpperLimites(double[] upperLimites) { 46 | this.upperLimites = upperLimites; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/conf/SimpleNetworkConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.conf; 2 | 3 | import org.aztec.dl4j.common.NetworkConfiguration; 4 | 5 | public class SimpleNetworkConfiguration extends BaseNetworkConfiguration implements NetworkConfiguration { 6 | 7 | public SimpleNetworkConfiguration(int inputNum,int outputNum) { 8 | super(inputNum,outputNum); 9 | } 10 | 11 | public NetworkConfigurationType getConfigType() { 12 | // TODO Auto-generated method stub 13 | return NetworkConfigurationType.SIMPLE; 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/CSVDataFileInfo.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.io.File; 4 | 5 | public class CSVDataFileInfo { 6 | 7 | private File file; 8 | private int batchSize; 9 | private int labelIndex; 10 | private int labelNums; 11 | private boolean normalized = false; 12 | 13 | public CSVDataFileInfo() { 14 | // TODO Auto-generated constructor stub 15 | } 16 | 17 | public CSVDataFileInfo(File file, int batchSize, int labelIndex, int labelNums) { 18 | super(); 19 | this.file = file; 20 | this.batchSize = batchSize; 21 | this.labelIndex = labelIndex; 22 | this.labelNums = labelNums; 23 | } 24 | 25 | public File getFile() { 26 | return file; 27 | } 28 | 29 | public void setFile(File file) { 30 | this.file = file; 31 | } 32 | 33 | public int getBatchSize() { 34 | return batchSize; 35 | } 36 | 37 | public void setBatchSize(int batchSize) { 38 | this.batchSize = batchSize; 39 | } 40 | 41 | public int getLabelIndex() { 42 | return labelIndex; 43 | } 44 | 45 | public void setLabelIndex(int labelIndex) { 46 | this.labelIndex = labelIndex; 47 | } 48 | 49 | public int getLabelNums() { 50 | return labelNums; 51 | } 52 | 53 | public void setLabelNums(int labelNums) { 54 | this.labelNums = labelNums; 55 | } 56 | 57 | public boolean isNormalized() { 58 | return normalized; 59 | } 60 | 61 | public void setNormalized(boolean normalized) { 62 | this.normalized = normalized; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/CSVDataSource.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | import java.util.Properties; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | import org.aztec.dl4j.common.utils.TrainningUtils; 9 | import org.deeplearning4j.arbiter.optimize.api.data.DataSource; 10 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | public class CSVDataSource extends ThreadGroupOptimizationDataSource implements DataSource { 15 | 16 | private static final Logger LOG = LoggerFactory.getLogger(CSVDataSource.class); 17 | private static final Map cachedSource = new ConcurrentHashMap(); 18 | 19 | public CSVDataSource(CSVDataFileInfo trainFile, CSVDataFileInfo testFile, Properties properties) 20 | throws IOException, InterruptedException { 21 | super(trainFile, testFile, properties); 22 | } 23 | 24 | public CSVDataSource() { 25 | 26 | } 27 | 28 | private String getSuffix(boolean train) { 29 | return train ? "_train" : "_test"; 30 | } 31 | 32 | private DataSetIterator getData(boolean train) { 33 | try { 34 | String sourceKey = getThreadGroupName() + getSuffix(train); 35 | DataSetIterator dsi = (DataSetIterator) cachedSource.get(sourceKey); 36 | if(dsi != null) { 37 | dsi.reset(); 38 | } 39 | else { 40 | CSVDataFileInfo trainFile = (CSVDataFileInfo) (train ? getTrainMetaData() : getTestMetaData()); 41 | dsi = TrainningUtils.csvToDataSet(trainFile); 42 | cachedSource.put(sourceKey, dsi); 43 | } 44 | return dsi; 45 | } catch (Exception e) { 46 | return null; 47 | } 48 | } 49 | 50 | public Object trainData() { 51 | return getData(true); 52 | } 53 | 54 | public Object testData() { 55 | return getData(false); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/CSVFileConfig.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | import org.aztec.dl4j.common.DataConvertor; 8 | 9 | public class CSVFileConfig { 10 | 11 | private File targetFile; 12 | private String seperator; 13 | private int beginLine; 14 | private Map convertors; 15 | 16 | public CSVFileConfig(File targetFile,String seperator, 17 | int beginLine) { 18 | this.targetFile = targetFile; 19 | this.seperator = seperator; 20 | this.beginLine = beginLine; 21 | this.convertors = new ConcurrentHashMap<>(); 22 | } 23 | 24 | public void addConverter(int line,DataConvertor convertor) { 25 | convertors.put(line, convertor); 26 | } 27 | 28 | public File getTargetFile() { 29 | return targetFile; 30 | } 31 | 32 | public void setTargetFile(File targetFile) { 33 | this.targetFile = targetFile; 34 | } 35 | 36 | public String getSeperator() { 37 | return seperator; 38 | } 39 | 40 | public void setSeperator(String seperator) { 41 | this.seperator = seperator; 42 | } 43 | 44 | public int getBeginLine() { 45 | return beginLine; 46 | } 47 | 48 | public void setBeginLine(int beginLine) { 49 | this.beginLine = beginLine; 50 | } 51 | 52 | public Map getConvertors() { 53 | return convertors; 54 | } 55 | 56 | public void setConvertors(Map convertors) { 57 | this.convertors = convertors; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/CSVFileReader.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.Map; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | 10 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 11 | 12 | public class CSVFileReader { 13 | 14 | private File targetFile; 15 | private int beginLine; 16 | 17 | 18 | 19 | public CSVFileReader(File tFile,int beginLine) { 20 | targetFile = tFile; 21 | this.beginLine = beginLine; 22 | } 23 | 24 | public DataSetIterator read(int batch) throws IOException { 25 | BufferedReader fr = new BufferedReader(new FileReader(targetFile)); 26 | 27 | String readLine = fr.readLine(); 28 | 29 | int lineNo = 0; 30 | while(readLine != null) { 31 | if(lineNo < beginLine) { 32 | lineNo++; 33 | continue; 34 | } 35 | System.out.println(readLine); 36 | lineNo++; 37 | readLine = fr.readLine(); 38 | } 39 | return null; 40 | } 41 | 42 | public static void main(String[] args) { 43 | try { 44 | CSVFileReader fileReader = new CSVFileReader(new File("E:/lm/ball/bet_roll_info.csv"), 1); 45 | fileReader.read(10); 46 | } catch (IOException e) { 47 | // TODO Auto-generated catch block 48 | e.printStackTrace(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/NetworkInput.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.util.List; 4 | 5 | import com.google.common.collect.Lists; 6 | 7 | public class NetworkInput { 8 | 9 | private double[] features; 10 | private double[] lables; 11 | private List labelNames; 12 | 13 | public NetworkInput(double[] features,double[] labels,List lableNames) { 14 | this.features = features; 15 | this.lables = labels; 16 | this.labelNames = lableNames; 17 | } 18 | 19 | 20 | public double[] getFeatures() { 21 | return features; 22 | } 23 | 24 | 25 | public void setFeatures(double[] features) { 26 | this.features = features; 27 | } 28 | 29 | 30 | public double[] getLables() { 31 | return lables; 32 | } 33 | 34 | 35 | public void setLables(double[] lables) { 36 | this.lables = lables; 37 | } 38 | 39 | 40 | public List getLabelNames() { 41 | return labelNames; 42 | } 43 | 44 | 45 | public void setLabelNames(List lableNames) { 46 | this.labelNames = lableNames; 47 | } 48 | 49 | public static List creataInputs(double[][] features,double[][] labelDatas,List labelNames){ 50 | 51 | List inputs = Lists.newArrayList(); 52 | for(int i = 0;i < features.length;i++) { 53 | inputs.add(new NetworkInput(features[i], labelDatas[i], labelNames)); 54 | } 55 | return inputs; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/NewsIterator.java: -------------------------------------------------------------------------------- 1 | /**- 2 | * This is a DataSetIterator that is specialized for the News headlines dataset used in the TrainNews example 3 | * It takes either the train or test set data from this data set, plus a WordVectors object generated by 4 | * PrepareWordVector.java program and generates training data sets.
5 | * Inputs/features: variable-length time series, where each word (with unknown words removed) is represented by 6 | * its Word2Vec vector representation.
7 | * Labels/target: a single class (representing category, i.e. 0,1,2 etc. depending on content of categories.txt 8 | * file mentioned in TrainNews.java program. 9 | *

10 | * Note : 11 | * - This program is a modification of original example named SentimentExampleIterator.java 12 | * - more details is given with each function's comments in the code 13 | *

14 | * KIT Solutions Pvt. Ltd. (www.kitsol.com) 15 | */ 16 | 17 | 18 | package org.aztec.dl4j.common.impl.data; 19 | 20 | import static org.nd4j.linalg.indexing.NDArrayIndex.all; 21 | import static org.nd4j.linalg.indexing.NDArrayIndex.point; 22 | 23 | import java.io.BufferedReader; 24 | import java.io.File; 25 | import java.io.FileReader; 26 | import java.io.IOException; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | import java.util.NoSuchElementException; 30 | 31 | import org.apache.commons.io.FileUtils; 32 | import org.apache.commons.lang3.tuple.Pair; 33 | import org.deeplearning4j.models.embeddings.wordvectors.WordVectors; 34 | import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory; 35 | import org.nd4j.linalg.api.ndarray.INDArray; 36 | import org.nd4j.linalg.dataset.DataSet; 37 | import org.nd4j.linalg.dataset.api.DataSetPreProcessor; 38 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 39 | import org.nd4j.linalg.factory.Nd4j; 40 | import org.nd4j.linalg.indexing.INDArrayIndex; 41 | 42 | public class NewsIterator implements DataSetIterator { 43 | private final WordVectors wordVectors; 44 | private final int batchSize; 45 | private final int vectorSize; 46 | private final int truncateLength; 47 | private int maxLength; 48 | private final String dataDirectory; 49 | private final List>> categoryData = new ArrayList<>(); 50 | private int cursor = 0; 51 | private int totalNews = 0; 52 | private final TokenizerFactory tokenizerFactory; 53 | private int newsPosition = 0; 54 | private final List labels; 55 | private int currCategory = 0; 56 | 57 | /** 58 | * @param dataDirectory the directory of the news headlines data set 59 | * @param wordVectors WordVectors object 60 | * @param batchSize Size of each minibatch for training 61 | * @param truncateLength If headline length exceed this size, it will be truncated to this size. 62 | * @param train If true: return the training data. If false: return the testing data. 63 | *

64 | * - initialize various class variables 65 | * - calls populateData function to load news data in categoryData vector 66 | * - also populates labels (i.e. category related inforamtion) in labels class variable 67 | */ 68 | private NewsIterator(String dataDirectory, 69 | WordVectors wordVectors, 70 | int batchSize, 71 | int truncateLength, 72 | boolean train, 73 | TokenizerFactory tokenizerFactory) { 74 | this.dataDirectory = dataDirectory; 75 | this.batchSize = batchSize; 76 | this.vectorSize = wordVectors.getWordVector(wordVectors.vocab().wordAtIndex(0)).length; 77 | this.wordVectors = wordVectors; 78 | this.truncateLength = truncateLength; 79 | this.tokenizerFactory = tokenizerFactory; 80 | this.populateData(train); 81 | this.labels = new ArrayList<>(); 82 | for (int i = 0; i < this.categoryData.size(); i++) { 83 | this.labels.add(this.categoryData.get(i).getKey().split(",")[1]); 84 | } 85 | } 86 | 87 | public static Builder Builder() { 88 | return new Builder(); 89 | } 90 | 91 | 92 | @Override 93 | public DataSet next(int num) { 94 | if (cursor >= this.totalNews) throw new NoSuchElementException(); 95 | try { 96 | return nextDataSet(num); 97 | } catch (IOException e) { 98 | throw new RuntimeException(e); 99 | } 100 | } 101 | 102 | private DataSet nextDataSet(int num) throws IOException { 103 | // Loads news into news list from categoryData List along with category of each news 104 | List news = new ArrayList<>(num); 105 | int[] category = new int[num]; 106 | 107 | for (int i = 0; i < num && cursor < this.totalNews; i++) { 108 | if (currCategory < categoryData.size()) { 109 | news.add(this.categoryData.get(currCategory).getValue().get(newsPosition)); 110 | category[i] = Integer.parseInt(this.categoryData.get(currCategory).getKey().split(",")[0]); 111 | currCategory++; 112 | cursor++; 113 | } else { 114 | currCategory = 0; 115 | newsPosition++; 116 | i--; 117 | } 118 | } 119 | 120 | //Second: tokenize news and filter out unknown words 121 | List> allTokens = new ArrayList<>(news.size()); 122 | maxLength = 0; 123 | for (String s : news) { 124 | List tokens = tokenizerFactory.create(s).getTokens(); 125 | List tokensFiltered = new ArrayList<>(); 126 | for (String t : tokens) { 127 | if (wordVectors.hasWord(t)) tokensFiltered.add(t); 128 | } 129 | allTokens.add(tokensFiltered); 130 | maxLength = Math.max(maxLength, tokensFiltered.size()); 131 | } 132 | 133 | //If longest news exceeds 'truncateLength': only take the first 'truncateLength' words 134 | //System.out.println("maxLength : " + maxLength); 135 | if (maxLength > truncateLength) maxLength = truncateLength; 136 | 137 | //Create data for training 138 | //Here: we have news.size() examples of varying lengths 139 | INDArray features = Nd4j.create(news.size(), vectorSize, maxLength); 140 | INDArray labels = Nd4j.create(news.size(), this.categoryData.size(), maxLength); //Three labels: Crime, Politics, Bollywood 141 | 142 | //Because we are dealing with news of different lengths and only one output at the final time step: use padding arrays 143 | //Mask arrays contain 1 if data is present at that time step for that example, or 0 if data is just padding 144 | INDArray featuresMask = Nd4j.zeros(news.size(), maxLength); 145 | INDArray labelsMask = Nd4j.zeros(news.size(), maxLength); 146 | 147 | int[] temp = new int[2]; 148 | for (int i = 0; i < news.size(); i++) { 149 | List tokens = allTokens.get(i); 150 | temp[0] = i; 151 | //Get word vectors for each word in news, and put them in the training data 152 | for (int j = 0; j < tokens.size() && j < maxLength; j++) { 153 | String token = tokens.get(j); 154 | INDArray vector = wordVectors.getWordVectorMatrix(token); 155 | features.put(new INDArrayIndex[]{point(i), 156 | all(), 157 | point(j)}, vector); 158 | 159 | temp[1] = j; 160 | featuresMask.putScalar(temp, 1.0); 161 | } 162 | int idx = category[i]; 163 | int lastIdx = Math.min(tokens.size(), maxLength); 164 | labels.putScalar(new int[]{i, idx, lastIdx - 1}, 1.0); 165 | labelsMask.putScalar(new int[]{i, lastIdx - 1}, 1.0); 166 | } 167 | 168 | DataSet ds = new DataSet(features, labels, featuresMask, labelsMask); 169 | return ds; 170 | } 171 | 172 | /** 173 | * Used post training to load a review from a file to a features INDArray that can be passed to the network output method 174 | * 175 | * @param file File to load the review from 176 | * @param maxLength Maximum length (if review is longer than this: truncate to maxLength). Use Integer.MAX_VALUE to not nruncate 177 | * @return Features array 178 | * @throws IOException If file cannot be read 179 | */ 180 | public INDArray loadFeaturesFromFile(File file, int maxLength) throws IOException { 181 | String news = FileUtils.readFileToString(file,"UTF-8"); 182 | return loadFeaturesFromString(news, maxLength); 183 | } 184 | 185 | /** 186 | * Used post training to convert a String to a features INDArray that can be passed to the network output method 187 | * 188 | * @param reviewContents Contents of the review to vectorize 189 | * @param maxLength Maximum length (if review is longer than this: truncate to maxLength). Use Integer.MAX_VALUE to not nruncate 190 | * @return Features array for the given input String 191 | */ 192 | public INDArray loadFeaturesFromString(String reviewContents, int maxLength) { 193 | List tokens = tokenizerFactory.create(reviewContents).getTokens(); 194 | List tokensFiltered = new ArrayList<>(); 195 | for (String t : tokens) { 196 | if (wordVectors.hasWord(t)) tokensFiltered.add(t); 197 | } 198 | int outputLength = Math.max(maxLength, tokensFiltered.size()); 199 | 200 | INDArray features = Nd4j.create(1, vectorSize, outputLength); 201 | 202 | for (int j = 0; j < tokens.size() && j < maxLength; j++) { 203 | String token = tokens.get(j); 204 | INDArray vector = wordVectors.getWordVectorMatrix(token); 205 | features.put(new INDArrayIndex[]{point(0), 206 | all(), 207 | point(j)}, vector); 208 | } 209 | 210 | return features; 211 | } 212 | 213 | /* 214 | This function loads news headlines from files stored in resources into categoryData List. 215 | */ 216 | private void populateData(boolean train) { 217 | File categories = new File(this.dataDirectory + File.separator + "categories.txt"); 218 | 219 | try (BufferedReader brCategories = new BufferedReader(new FileReader(categories))) { 220 | String temp = ""; 221 | while ((temp = brCategories.readLine()) != null) { 222 | String curFileName = train == true ? 223 | this.dataDirectory + File.separator + "train" + File.separator + temp.split(",")[0] + ".txt" : 224 | this.dataDirectory + File.separator + "test" + File.separator + temp.split(",")[0] + ".txt"; 225 | File currFile = new File(curFileName); 226 | BufferedReader currBR = new BufferedReader((new FileReader(currFile))); 227 | String tempCurrLine = ""; 228 | List tempList = new ArrayList<>(); 229 | while ((tempCurrLine = currBR.readLine()) != null) { 230 | tempList.add(tempCurrLine); 231 | this.totalNews++; 232 | } 233 | currBR.close(); 234 | Pair> tempPair = Pair.of(temp, tempList); 235 | this.categoryData.add(tempPair); 236 | } 237 | brCategories.close(); 238 | } catch (Exception e) { 239 | System.out.println("Exception in reading file :" + e.getMessage()); 240 | } 241 | } 242 | 243 | @Override 244 | public int inputColumns() { 245 | return vectorSize; 246 | } 247 | 248 | @Override 249 | public int totalOutcomes() { 250 | return this.categoryData.size(); 251 | } 252 | 253 | @Override 254 | public void reset() { 255 | cursor = 0; 256 | newsPosition = 0; 257 | currCategory = 0; 258 | } 259 | 260 | public boolean resetSupported() { 261 | return true; 262 | } 263 | 264 | @Override 265 | public boolean asyncSupported() { 266 | return true; 267 | } 268 | 269 | @Override 270 | public int batch() { 271 | return batchSize; 272 | } 273 | 274 | @Override 275 | public void setPreProcessor(DataSetPreProcessor preProcessor) { 276 | throw new UnsupportedOperationException(); 277 | } 278 | 279 | @Override 280 | public List getLabels() { 281 | return this.labels; 282 | } 283 | 284 | @Override 285 | public boolean hasNext() { 286 | return cursor < this.totalNews; 287 | } 288 | 289 | @Override 290 | public DataSet next() { 291 | return next(batchSize); 292 | } 293 | 294 | @Override 295 | public void remove() { 296 | 297 | } 298 | 299 | @Override 300 | public DataSetPreProcessor getPreProcessor() { 301 | throw new UnsupportedOperationException("Not implemented"); 302 | } 303 | 304 | public int getMaxLength() { 305 | return this.maxLength; 306 | } 307 | 308 | public static class Builder { 309 | private String dataDirectory; 310 | private WordVectors wordVectors; 311 | private int batchSize; 312 | private int truncateLength; 313 | TokenizerFactory tokenizerFactory; 314 | private boolean train; 315 | 316 | Builder() { 317 | } 318 | 319 | public NewsIterator.Builder dataDirectory(String dataDirectory) { 320 | this.dataDirectory = dataDirectory; 321 | return this; 322 | } 323 | 324 | public NewsIterator.Builder wordVectors(WordVectors wordVectors) { 325 | this.wordVectors = wordVectors; 326 | return this; 327 | } 328 | 329 | public NewsIterator.Builder batchSize(int batchSize) { 330 | this.batchSize = batchSize; 331 | return this; 332 | } 333 | 334 | public NewsIterator.Builder truncateLength(int truncateLength) { 335 | this.truncateLength = truncateLength; 336 | return this; 337 | } 338 | 339 | public NewsIterator.Builder train(boolean train) { 340 | this.train = train; 341 | return this; 342 | } 343 | 344 | public NewsIterator.Builder tokenizerFactory(TokenizerFactory tokenizerFactory) { 345 | this.tokenizerFactory = tokenizerFactory; 346 | return this; 347 | } 348 | 349 | public NewsIterator build() { 350 | return new NewsIterator(dataDirectory, 351 | wordVectors, 352 | batchSize, 353 | truncateLength, 354 | train, 355 | tokenizerFactory); 356 | } 357 | 358 | public String toString() { 359 | return "org.deeplearning4j.examples.recurrent.ProcessNews.NewsIterator.Builder(dataDirectory=" + 360 | this.dataDirectory + ", wordVectors=" + this.wordVectors + 361 | ", batchSize=" + this.batchSize + ", truncateLength=" 362 | + this.truncateLength + ", train=" + this.train + ")"; 363 | } 364 | } 365 | } 366 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/PrepareWordVector.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.deeplearning4j.models.embeddings.loader.WordVectorSerializer; 7 | import org.deeplearning4j.models.word2vec.Word2Vec; 8 | import org.deeplearning4j.text.sentenceiterator.BasicLineIterator; 9 | import org.deeplearning4j.text.sentenceiterator.SentenceIterator; 10 | import org.deeplearning4j.text.tokenization.tokenizer.preprocessor.CommonPreprocessor; 11 | import org.deeplearning4j.text.tokenization.tokenizerfactory.DefaultTokenizerFactory; 12 | import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | /**- 17 | * This program generates a word-vector from news items stored in resources folder. 18 | * News File is located at \dl4j-examples\src\main\resources\NewsData\RawNewsToGenerateWordVector.txt 19 | * Word vector file : \dl4j-examples\src\main\resources\NewsData\NewsWordVector.txt 20 | * Note : 21 | * 1) This code is modification of original example named Word2VecRawTextExample.java 22 | * 2) Word vector generated in this program is used in Training RNN to categorise news headlines. 23 | *

24 | * KIT Solutions Pvt. Ltd. (www.kitsol.com) 25 | */ 26 | public class PrepareWordVector { 27 | 28 | private static Logger log = LoggerFactory.getLogger(PrepareWordVector.class); 29 | 30 | public static void main(String[] args) throws Exception { 31 | 32 | //5Y+q54uX6KaB56iz6bih6K6y5pWw 33 | //generateWordVectors(); 34 | generateWordVectors(new File("test/rnn/Cantonese.txt"), new File("test/rnn/CantoneseVector.txt")); 35 | } 36 | 37 | 38 | public static void generateWordVectors(File rawFile,File vectorFile) throws IOException { 39 | // Gets Path to Text file 40 | String filePath = rawFile.getAbsolutePath(); 41 | 42 | log.info("Load & Vectorize Sentences...."); 43 | // Strip white space before and after for each line 44 | SentenceIterator iter = new BasicLineIterator(filePath); 45 | // Split on white spaces in the line to get words 46 | TokenizerFactory t = new DefaultTokenizerFactory(); 47 | 48 | //CommonPreprocessor will apply the following regex to each token: [\d\.:,"'\(\)\[\]|/?!;]+ 49 | //So, effectively all numbers, punctuation symbols and some special symbols are stripped off. 50 | //Additionally it forces lower case for all tokens. 51 | t.setTokenPreProcessor(new CommonPreprocessor()); 52 | 53 | log.info("Building model...."); 54 | Word2Vec vec = new Word2Vec.Builder() 55 | .minWordFrequency(2) 56 | .iterations(5) 57 | .layerSize(100) 58 | .seed(42) 59 | .windowSize(20) 60 | .iterate(iter) 61 | .tokenizerFactory(t) 62 | .build(); 63 | 64 | log.info("Fitting Word2Vec model...."); 65 | vec.fit(); 66 | 67 | log.info("Writing word vectors to text file...."); 68 | // Write word vectors to file 69 | WordVectorSerializer.writeWordVectors(vec.lookupTable(), vectorFile.getAbsolutePath()); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/SimpleTensorIterator.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | 6 | import org.nd4j.linalg.api.ndarray.INDArray; 7 | import org.nd4j.linalg.dataset.DataSet; 8 | import org.nd4j.linalg.dataset.api.DataSetPreProcessor; 9 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 10 | import org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize; 11 | import org.nd4j.linalg.factory.Nd4j; 12 | 13 | import com.google.common.collect.Lists; 14 | 15 | 16 | public class SimpleTensorIterator implements DataSetIterator { 17 | 18 | 19 | protected List datas; 20 | protected Iterator trainningDatas; 21 | protected List labels; 22 | protected int inputNums; 23 | protected DataSetPreProcessor preprocessor; 24 | protected int batch; 25 | protected boolean normalized = false; 26 | 27 | public SimpleTensorIterator() { 28 | datas = Lists.newArrayList(); 29 | labels = Lists.newArrayList(); 30 | preprocessor = new NormalizerStandardize(); 31 | } 32 | 33 | 34 | public SimpleTensorIterator(List features,List labelDatas,List labelNames,int batch) { 35 | init(toDoubleArray(features),toDoubleArray(labelDatas),labelNames,batch); 36 | } 37 | 38 | public void appendDataSet(List features,List labelDatas) { 39 | datas.add(getDataSet(toDoubleArray(features),toDoubleArray(labelDatas))); 40 | trainningDatas = datas.iterator(); 41 | } 42 | 43 | 44 | private double[][] toDoubleArray(List dataList){ 45 | double[][] retArray = new double[dataList.size()][]; 46 | for(int i = 0;i < dataList.size();i++) { 47 | Double[] dataListArray = dataList.get(i); 48 | double[] doubleArray = new double[dataListArray.length]; 49 | for(int j = 0; j < dataListArray.length;j++) { 50 | doubleArray[j] = dataListArray[j].doubleValue(); 51 | } 52 | retArray[i] = doubleArray; 53 | } 54 | return retArray; 55 | } 56 | 57 | public SimpleTensorIterator(double[][] features,double[][] labelDatas,List labelNames,int batch) { 58 | init(features,labelDatas,labelNames,batch); 59 | } 60 | 61 | public SimpleTensorIterator(NetworkInput input) { 62 | init(Lists.newArrayList(input),1); 63 | } 64 | 65 | public SimpleTensorIterator(List inputs,int batch) { 66 | init(inputs,batch); 67 | } 68 | 69 | private void init(double[][] features,double[][] lables,List labelNames,int batch) { 70 | List dataList = Lists.newArrayList(); 71 | inputNums = features.length; 72 | dataList.add(getDataSet(features, lables)); 73 | trainningDatas = dataList.iterator(); 74 | this.batch = batch; 75 | datas = Lists.newArrayList(); 76 | datas.addAll(dataList); 77 | preprocessor = new NormalizerStandardize(); 78 | } 79 | 80 | private void init(List inputs,int batch) { 81 | List dataList = Lists.newArrayList(); 82 | double[][] features = new double[inputs.size()][]; 83 | double[][] labels = new double[inputs.size()][]; 84 | for(int i = 0;i < inputs.size();i++) { 85 | NetworkInput input = inputs.get(i); 86 | inputNums = input.getFeatures().length; 87 | if(this.labels == null && input.getLabelNames() != null) { 88 | this.labels = input.getLabelNames(); 89 | } 90 | features[i] = inputs.get(i).getFeatures(); 91 | labels[i] = inputs.get(i).getLables(); 92 | } 93 | dataList.add(getDataSet(features, labels)); 94 | /*for(NetworkInput input : inputs) { 95 | inputNums = input.getFeatures().length; 96 | if(labels == null && input.getLabelNames() != null) { 97 | labels = input.getLabelNames(); 98 | } 99 | dataList.add(getDataSet(input.getFeatures(), input.getLables())); 100 | }*/ 101 | trainningDatas = dataList.iterator(); 102 | this.batch = batch; 103 | datas = Lists.newArrayList(); 104 | datas.addAll(dataList); 105 | preprocessor = new NormalizerStandardize(); 106 | } 107 | 108 | private DataSet getDataSet(double[] featureRawDatas,double[] lableRawDatas) { 109 | 110 | INDArray features = Nd4j.create(featureRawDatas); 111 | INDArray lables = null; 112 | if(lableRawDatas != null) { 113 | lables = Nd4j.create(lableRawDatas); 114 | } 115 | return new DataSet(features, lables); 116 | } 117 | 118 | private DataSet getDataSet(double[][] featureRawDatas,double[][] lableRawDatas) { 119 | 120 | INDArray features = Nd4j.create(featureRawDatas); 121 | INDArray lables = null; 122 | if(lableRawDatas != null && lableRawDatas.length > 0) { 123 | lables = Nd4j.create(lableRawDatas); 124 | } 125 | return new DataSet(features, lables); 126 | } 127 | 128 | public boolean hasNext() { 129 | // TODO Auto-generated method stub 130 | return trainningDatas.hasNext(); 131 | } 132 | 133 | public DataSet next() { 134 | // TODO Auto-generated method stub 135 | return trainningDatas.next(); 136 | } 137 | 138 | public DataSet next(int num) { 139 | // TODO Auto-generated method stubf 140 | for(int i = 0;i < num;i++) { 141 | trainningDatas.next(); 142 | } 143 | return trainningDatas.next(); 144 | } 145 | 146 | public int inputColumns() { 147 | // TODO Auto-generated method stub 148 | return inputNums; 149 | } 150 | 151 | public int totalOutcomes() { 152 | // TODO Auto-generated method stub 153 | return labels.size(); 154 | } 155 | 156 | public boolean resetSupported() { 157 | // TODO Auto-generated method stub 158 | return false; 159 | } 160 | 161 | public boolean asyncSupported() { 162 | // TODO Auto-generated method stub 163 | return false; 164 | } 165 | 166 | public void reset() { 167 | // TODO Auto-generated method stub 168 | trainningDatas = datas.iterator(); 169 | } 170 | 171 | public int batch() { 172 | // TODO Auto-generated method stub 173 | return batch; 174 | } 175 | 176 | public void setPreProcessor(DataSetPreProcessor preProcessor) { 177 | // TODO Auto-generated method stub 178 | this.preprocessor = preProcessor; 179 | } 180 | 181 | public DataSetPreProcessor getPreProcessor() { 182 | // TODO Auto-generated method stub 183 | return preprocessor; 184 | } 185 | 186 | public List getLabels() { 187 | return labels; 188 | } 189 | 190 | public boolean isNormalized() { 191 | return normalized; 192 | } 193 | 194 | public void setNormalized(boolean flag) { 195 | // TODO Auto-generated method stub 196 | normalized = flag; 197 | } 198 | 199 | public void addDataSet(DataSet set) { 200 | datas.add(set); 201 | } 202 | 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/ThreadGroupOptimizationDataSource.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import java.util.Map; 4 | import java.util.Properties; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | import org.deeplearning4j.arbiter.optimize.api.data.DataSource; 8 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 9 | 10 | public abstract class ThreadGroupOptimizationDataSource implements DataSource { 11 | 12 | /** 13 | * 14 | */ 15 | private static final long serialVersionUID = -8372324498345738745L; 16 | private static final Map trainingMetaData = new ConcurrentHashMap(); 17 | private static final Map testMetaData = new ConcurrentHashMap(); 18 | private static final Map configProperties = new ConcurrentHashMap(); 19 | private int minibatchSize; 20 | 21 | public ThreadGroupOptimizationDataSource(Object trData,Object teData,Properties props) { 22 | //trainData.set(trData); 23 | //testData.set(teData); 24 | String threadGroupName = getThreadGroupName(); 25 | trainingMetaData.put(threadGroupName, trData); 26 | testMetaData.put(threadGroupName, teData); 27 | this.configProperties.put(threadGroupName,props); 28 | } 29 | 30 | public ThreadGroupOptimizationDataSource() { 31 | 32 | } 33 | 34 | public void configure(Properties properties) { 35 | this.minibatchSize = Integer.parseInt(properties.getProperty("minibatchSize", "16")); 36 | } 37 | 38 | 39 | public T getTrainMetaData() { 40 | try { 41 | 42 | return (T) trainingMetaData.get(getThreadGroupName()); 43 | 44 | } catch (Exception e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | 49 | public T getTestMetaData() { 50 | try { 51 | return (T) testMetaData.get(getThreadGroupName()); 52 | 53 | } catch (Exception e) { 54 | throw new RuntimeException(e); 55 | } 56 | } 57 | 58 | public Class getDataType() { 59 | return DataSetIterator.class; 60 | } 61 | 62 | public Properties getConfigProperties() { 63 | return configProperties.get(getThreadGroupName()); 64 | } 65 | 66 | 67 | protected String getThreadGroupName() { 68 | return Thread.currentThread().getThreadGroup().getName(); 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/TrainNews.java: -------------------------------------------------------------------------------- 1 | /**- 2 | * This program trains a RNN to predict category of a news headlines. It uses word vector generated from PrepareWordVector.java. 3 | * - Labeled News are stored in \dl4j-examples\src\main\resources\NewsData\LabelledNews folder in train and test folders. 4 | * - categories.txt file in \dl4j-examples\src\main\resources\NewsData\LabelledNews folder contains category code and description. 5 | * - This categories are used along with actual news for training. 6 | * - news word vector is contained in \dl4j-examples\src\main\resources\NewsData\NewsWordVector.txt file. 7 | * - Trained model is stored in \dl4j-examples\src\main\resources\NewsData\NewsModel.net file 8 | * - News Data contains only 3 categories currently. 9 | * - Data set structure is as given below 10 | * - categories.txt - this file contains various categories in category id,category description format. Sample categories are as below 11 | * 0,crime 12 | * 1,politics 13 | * 2,bollywood 14 | * 3,Business&Development 15 | * - For each category id above, there is a file containig actual news headlines, e.g. 16 | * 0.txt - contains news for crime headlines 17 | * 1.txt - contains news for politics headlines 18 | * 2.txt - contains news for bollywood 19 | * 3.txt - contains news for Business&Development 20 | * - You can add any new category by adding one line in categories.txt and respective news file in folder mentioned above. 21 | * - Below are training results with the news data given with this example. 22 | * ==========================Scores======================================== 23 | * Accuracy: 0.9343 24 | * Precision: 0.9249 25 | * Recall: 0.9327 26 | * F1 Score: 0.9288 27 | * ======================================================================== 28 | *

29 | * Note : 30 | * - This code is a modification of original example named Word2VecSentimentRNN.java 31 | * - Results may vary with the data you use to train this network 32 | *

33 | * KIT Solutions Pvt. Ltd. (www.kitsol.com) 34 | */ 35 | 36 | package org.aztec.dl4j.common.impl.data; 37 | 38 | import org.datavec.api.util.ClassPathResource; 39 | import org.deeplearning4j.eval.Evaluation; 40 | import org.deeplearning4j.models.embeddings.loader.WordVectorSerializer; 41 | import org.deeplearning4j.models.embeddings.wordvectors.WordVectors; 42 | import org.deeplearning4j.nn.conf.GradientNormalization; 43 | import org.deeplearning4j.nn.conf.MultiLayerConfiguration; 44 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration; 45 | import org.deeplearning4j.nn.conf.layers.LSTM; 46 | import org.deeplearning4j.nn.conf.layers.RnnOutputLayer; 47 | import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; 48 | import org.deeplearning4j.nn.weights.WeightInit; 49 | import org.deeplearning4j.optimize.listeners.ScoreIterationListener; 50 | import org.deeplearning4j.text.tokenization.tokenizer.preprocessor.CommonPreprocessor; 51 | import org.deeplearning4j.text.tokenization.tokenizerfactory.DefaultTokenizerFactory; 52 | import org.deeplearning4j.text.tokenization.tokenizerfactory.TokenizerFactory; 53 | import org.deeplearning4j.util.ModelSerializer; 54 | import org.nd4j.linalg.activations.Activation; 55 | import org.nd4j.linalg.learning.config.RmsProp; 56 | import org.nd4j.linalg.lossfunctions.LossFunctions; 57 | 58 | import java.io.File; 59 | 60 | public class TrainNews { 61 | public static String userDirectory = ""; 62 | public static String DATA_PATH = ""; 63 | public static String WORD_VECTORS_PATH = ""; 64 | public static WordVectors wordVectors; 65 | private static TokenizerFactory tokenizerFactory; 66 | 67 | public static void main(String[] args) throws Exception { 68 | userDirectory = new File("test/rnn/").getAbsolutePath() + File.separator; 69 | DATA_PATH = userDirectory + "dialect"; 70 | WORD_VECTORS_PATH = userDirectory + "CantoneseVector.txt"; 71 | 72 | int batchSize = 2; //Number of examples in each minibatch 73 | int nEpochs = 1000; //Number of epochs (full passes of training data) to train on 74 | int truncateReviewsToLength = 300; //Truncate reviews with length (# words) greater than this 75 | 76 | //DataSetIterators for training and testing respectively 77 | //Using AsyncDataSetIterator to do data loading in a separate thread; this may improve performance vs. waiting for data to load 78 | wordVectors = WordVectorSerializer.readWord2VecModel(new File(WORD_VECTORS_PATH)); 79 | 80 | TokenizerFactory tokenizerFactory = new DefaultTokenizerFactory(); 81 | tokenizerFactory.setTokenPreProcessor(new CommonPreprocessor()); 82 | 83 | NewsIterator iTrain = new NewsIterator.Builder() 84 | .dataDirectory(DATA_PATH) 85 | .wordVectors(wordVectors) 86 | .batchSize(batchSize) 87 | .truncateLength(truncateReviewsToLength) 88 | .tokenizerFactory(tokenizerFactory) 89 | .train(true) 90 | .build(); 91 | 92 | NewsIterator iTest = new NewsIterator.Builder() 93 | .dataDirectory(DATA_PATH) 94 | .wordVectors(wordVectors) 95 | .batchSize(batchSize) 96 | .tokenizerFactory(tokenizerFactory) 97 | .truncateLength(truncateReviewsToLength) 98 | .train(false) 99 | .build(); 100 | 101 | //DataSetIterator train = new AsyncDataSetIterator(iTrain,1); 102 | //DataSetIterator test = new AsyncDataSetIterator(iTest,1); 103 | 104 | int inputNeurons = wordVectors.getWordVector(wordVectors.vocab().wordAtIndex(0)).length; // 100 in our case 105 | int outputs = iTrain.getLabels().size(); 106 | 107 | tokenizerFactory = new DefaultTokenizerFactory(); 108 | tokenizerFactory.setTokenPreProcessor(new CommonPreprocessor()); 109 | //Set up network configuration 110 | MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder() 111 | .updater(new RmsProp(0.0018)) 112 | .l2(1e-5) 113 | .weightInit(WeightInit.XAVIER) 114 | .gradientNormalization(GradientNormalization.ClipElementWiseAbsoluteValue).gradientNormalizationThreshold(1.0) 115 | .list() 116 | .layer(0, new LSTM.Builder().nIn(inputNeurons).nOut(200) 117 | .activation(Activation.SOFTSIGN).build()) 118 | .layer(1, new RnnOutputLayer.Builder().activation(Activation.SOFTMAX) 119 | .lossFunction(LossFunctions.LossFunction.MCXENT).nIn(200).nOut(outputs).build()) 120 | .pretrain(false).backprop(true).build(); 121 | 122 | MultiLayerNetwork net = new MultiLayerNetwork(conf); 123 | net.init(); 124 | net.setListeners(new ScoreIterationListener(1)); 125 | 126 | System.out.println("Starting training"); 127 | for (int i = 0; i < nEpochs; i++) { 128 | net.fit(iTrain); 129 | iTrain.reset(); 130 | System.out.println("Epoch " + i + " complete. Starting evaluation:"); 131 | 132 | //Run evaluation. This is on 25k reviews, so can take some time 133 | Evaluation evaluation = net.evaluate(iTest); 134 | 135 | System.out.println(evaluation.stats()); 136 | } 137 | 138 | ModelSerializer.writeModel(net, userDirectory + "NewsModel.net", true); 139 | System.out.println("----- Example complete -----"); 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/data/UTF8TextConverter.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.data; 2 | 3 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException; 4 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException.ErrorCode; 5 | import org.aztec.dl4j.common.DataConvertor; 6 | import org.aztec.dl4j.common.utils.StringUtils; 7 | 8 | public class UTF8TextConverter implements DataConvertor{ 9 | 10 | public UTF8TextConverter() { 11 | // TODO Auto-generated constructor stub 12 | } 13 | 14 | @Override 15 | public double convert(String text) throws ArtificialNeuralNetworkException { 16 | try { 17 | String base64 = StringUtils.utf8ToBase64(text); 18 | return new Double(base64.hashCode()); 19 | } catch (Exception e) { 20 | throw new ArtificialNeuralNetworkException(e.getMessage(), ErrorCode.CONVERT_ERROR); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/network/AutomaticBPNetwork.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.network; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.List; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import org.aztec.dl4j.common.AritificialNerualNetworkFactory; 9 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException; 10 | import org.aztec.dl4j.common.LayerConfiguration; 11 | import org.aztec.dl4j.common.NetworkConfiguration; 12 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException.ErrorCode; 13 | import org.aztec.dl4j.common.impl.conf.AutomaticNetwokConfiguration; 14 | import org.deeplearning4j.arbiter.MultiLayerSpace; 15 | import org.deeplearning4j.arbiter.MultiLayerSpace.Builder; 16 | import org.deeplearning4j.arbiter.conf.updater.SgdSpace; 17 | import org.deeplearning4j.arbiter.layers.DenseLayerSpace; 18 | import org.deeplearning4j.arbiter.layers.OutputLayerSpace; 19 | import org.deeplearning4j.arbiter.optimize.api.CandidateGenerator; 20 | import org.deeplearning4j.arbiter.optimize.api.OptimizationResult; 21 | import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; 22 | import org.deeplearning4j.arbiter.optimize.api.data.DataSource; 23 | import org.deeplearning4j.arbiter.optimize.api.saving.ResultReference; 24 | import org.deeplearning4j.arbiter.optimize.api.saving.ResultSaver; 25 | import org.deeplearning4j.arbiter.optimize.api.score.ScoreFunction; 26 | import org.deeplearning4j.arbiter.optimize.api.termination.MaxCandidatesCondition; 27 | import org.deeplearning4j.arbiter.optimize.api.termination.MaxTimeCondition; 28 | import org.deeplearning4j.arbiter.optimize.api.termination.TerminationCondition; 29 | import org.deeplearning4j.arbiter.optimize.config.OptimizationConfiguration; 30 | import org.deeplearning4j.arbiter.optimize.generator.RandomSearchGenerator; 31 | import org.deeplearning4j.arbiter.optimize.parameter.continuous.ContinuousParameterSpace; 32 | import org.deeplearning4j.arbiter.optimize.parameter.integer.IntegerParameterSpace; 33 | import org.deeplearning4j.arbiter.optimize.runner.IOptimizationRunner; 34 | import org.deeplearning4j.arbiter.optimize.runner.LocalOptimizationRunner; 35 | import org.deeplearning4j.arbiter.saver.local.FileModelSaver; 36 | import org.deeplearning4j.arbiter.scoring.impl.EvaluationScoreFunction; 37 | import org.deeplearning4j.arbiter.task.MultiLayerNetworkTaskCreator; 38 | import org.deeplearning4j.eval.Evaluation; 39 | import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; 40 | import org.deeplearning4j.nn.weights.WeightInit; 41 | 42 | public class AutomaticBPNetwork extends BaseNetwork{ 43 | 44 | public AutomaticBPNetwork() { 45 | // TODO Auto-generated constructor stub 46 | } 47 | 48 | public void doBuild(NetworkConfiguration networkConfig) throws ArtificialNeuralNetworkException { 49 | 50 | AutomaticNetwokConfiguration autoConfig = networkConfig.adapt(AutomaticNetwokConfiguration.class); 51 | 52 | ParameterSpace learningRateHyperparam = new ContinuousParameterSpace(autoConfig.getRatioRanges()[0], 53 | autoConfig.getRatioRanges()[1]); //Values will be generated uniformly at random between 0.0001 and 0.1 (inclusive) 54 | ParameterSpace layerSizeHyperparam = new IntegerParameterSpace(autoConfig.getHiddenLayerNeuronNumRanges()[0], 55 | autoConfig.getHiddenLayerNeuronNumRanges()[1]); //Integer values will be generated uniformly at random between 16 and 256 (inclusive) 56 | ParameterSpace biasHyperparam = new ContinuousParameterSpace(autoConfig.getBiasRanges()[0], 57 | autoConfig.getBiasRanges()[1]); 58 | Builder spaceBuilder = new MultiLayerSpace.Builder()//These next few options: fixed values for all models 59 | .weightInit(WeightInit.XAVIER) 60 | .l1(autoConfig.getL1()) 61 | .l2(autoConfig.getL2()) 62 | //Learning rate hyperparameter: search over different values, applied to all models 63 | .updater(new SgdSpace(learningRateHyperparam)); 64 | List layers = networkConfig.getLayers(); 65 | 66 | for(int i = 0;i < layers.size();i++) { 67 | LayerConfiguration layer = layers.get(i); 68 | if(i == 0) { 69 | spaceBuilder = spaceBuilder.addLayer(new DenseLayerSpace.Builder() 70 | .nIn(layer.getInputNum()) 71 | .activation(layer.getActiavtion()) 72 | .nOut(layerSizeHyperparam) 73 | .biasInit(biasHyperparam) 74 | .weightInit(layer.getWeightInit()) 75 | .build()); 76 | } 77 | else { 78 | switch(layer.getType()) { 79 | case DENSE: 80 | spaceBuilder = spaceBuilder.addLayer(new DenseLayerSpace.Builder() 81 | .activation(layer.getActiavtion()) 82 | .nOut(layerSizeHyperparam) 83 | .biasInit(biasHyperparam) 84 | .weightInit(layer.getWeightInit()) 85 | .build()); 86 | break; 87 | case OUTPUT: 88 | 89 | spaceBuilder = spaceBuilder.addLayer(new OutputLayerSpace.Builder() 90 | .nOut(layer.getOutputNum()) 91 | .biasInit(biasHyperparam) 92 | .activation(layer.getActiavtion()) 93 | .lossFunction(layer.getLossFunction()) 94 | .weightInit(layer.getWeightInit()) 95 | .build()); 96 | break; 97 | } 98 | } 99 | } 100 | 101 | MultiLayerSpace hyperparameterSpace = spaceBuilder.numEpochs(150).build(); 102 | 103 | CandidateGenerator candidateGenerator = new RandomSearchGenerator(hyperparameterSpace, null); 104 | File f = autoConfig.getWorkingDir(); 105 | if (f.exists()) f.delete(); 106 | f.mkdir(); 107 | ResultSaver modelSaver = new FileModelSaver(f.getPath()); 108 | ScoreFunction scoreFunction = new EvaluationScoreFunction(Evaluation.Metric.ACCURACY); 109 | TerminationCondition[] terminationConditions = { 110 | new MaxTimeCondition(autoConfig.getTimeout(), TimeUnit.MILLISECONDS), 111 | new MaxCandidatesCondition(autoConfig.getMaxCandidateNum())}; 112 | 113 | OptimizationConfiguration configuration = new OptimizationConfiguration.Builder() 114 | .candidateGenerator(candidateGenerator) 115 | .dataSource(autoConfig.getDataSource().getClass(),autoConfig.getConfigProperties()) 116 | .modelSaver(modelSaver) 117 | .scoreFunction(scoreFunction) 118 | .terminationConditions(terminationConditions) 119 | .build(); 120 | 121 | IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator()); 122 | runner.execute(); 123 | int indexOfBestResult = runner.bestScoreCandidateIndex(); 124 | String s = "Best score: " + runner.bestScore() + "\n" + 125 | "Index of model with best score: " + runner.bestScoreCandidateIndex() + "\n" + 126 | "Number of configurations evaluated: " + runner.numCandidatesCompleted() + "\n"; 127 | System.out.println(s); 128 | if(indexOfBestResult != -1) { 129 | 130 | List allResults = runner.getResults(); 131 | 132 | try { 133 | OptimizationResult bestResult = allResults.get(indexOfBestResult).getResult(); 134 | network = (MultiLayerNetwork) bestResult.getResultReference().getResultModel(); 135 | } catch (IOException e) { 136 | throw new ArtificialNeuralNetworkException("IO Error!", ErrorCode.IO_ERROR); 137 | } 138 | 139 | System.out.println("\n\nConfiguration of best model:\n"); 140 | System.out.println(network.getLayerWiseConfigurations().toJson()); 141 | } 142 | else { 143 | System.err.println("model train fail!!!"); 144 | } 145 | } 146 | 147 | 148 | 149 | } 150 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/network/BaseNetwork.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.network; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.aztec.dl4j.common.ArtificialNeuralNetwork; 7 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException; 8 | import org.aztec.dl4j.common.NetworkConfiguration; 9 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException.ErrorCode; 10 | import org.aztec.dl4j.common.utils.NormalizeUtils; 11 | import org.deeplearning4j.eval.Evaluation; 12 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration.Builder; 13 | import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; 14 | import org.nd4j.linalg.api.ndarray.INDArray; 15 | import org.nd4j.linalg.dataset.DataSet; 16 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 17 | import org.nd4j.linalg.factory.Nd4j; 18 | 19 | public abstract class BaseNetwork implements ArtificialNeuralNetwork { 20 | 21 | protected Builder networkBuilder; 22 | protected MultiLayerNetwork network; 23 | 24 | public BaseNetwork() { 25 | // TODO Auto-generated constructor stub 26 | } 27 | 28 | protected abstract void doBuild(NetworkConfiguration networkConfig) throws ArtificialNeuralNetworkException; 29 | 30 | public void buildNetwork(NetworkConfiguration networkConfig) throws ArtificialNeuralNetworkException { 31 | networkConfig.init(); 32 | doBuild(networkConfig); 33 | } 34 | 35 | public void train(DataSetIterator trainningDatas, int numEpochs, boolean normalized) 36 | throws ArtificialNeuralNetworkException { 37 | if (network == null) { 38 | throw new ArtificialNeuralNetworkException("Network not build!", ErrorCode.NETWORK_NOT_BUILD); 39 | } 40 | DataSetIterator normalizedDatas = trainningDatas; 41 | if (!normalized) { 42 | normalizedDatas = normalize(trainningDatas); 43 | } 44 | network.pretrain(normalizedDatas); 45 | for (int i = 0; i < numEpochs; i++) { 46 | network.fit(normalizedDatas); 47 | // preprocess(trainningDatas); 48 | // normalizedDatas.reset(); 49 | } 50 | } 51 | 52 | public double[] predict(double[] features) throws ArtificialNeuralNetworkException { 53 | if (network == null) { 54 | throw new ArtificialNeuralNetworkException("Network not build!", ErrorCode.NETWORK_NOT_BUILD); 55 | } 56 | if (features != null && features.length > 0) { 57 | INDArray outArray = network.output(Nd4j.create(features)); 58 | return outArray.toDoubleVector(); 59 | } 60 | 61 | return null; 62 | } 63 | 64 | public void save(File file) throws IOException { 65 | // TODO Auto-generated method stub 66 | if (network != null) { 67 | network.save(file, true); 68 | } 69 | } 70 | 71 | public void load(File file) throws IOException { 72 | if (file != null && file.exists()) { 73 | network = MultiLayerNetwork.load(file, true); 74 | } 75 | } 76 | 77 | public Evaluation validate(DataSetIterator dataSet, int outputNum, boolean normalized) 78 | throws ArtificialNeuralNetworkException { 79 | if (network == null) { 80 | throw new ArtificialNeuralNetworkException("Network not build!", ErrorCode.NETWORK_NOT_BUILD); 81 | } 82 | DataSetIterator normalizedDatas = dataSet; 83 | if (!normalized) { 84 | normalizedDatas = normalize(dataSet); 85 | } 86 | Evaluation eval = new Evaluation(outputNum); // create an evaluation object with 10 possible classes 87 | if (normalizedDatas.resetSupported()) { 88 | normalizedDatas.reset(); 89 | } 90 | while (normalizedDatas.hasNext()) { 91 | DataSet next = normalizedDatas.next(); 92 | INDArray output = network.output(next.getFeatures()); // get the networks prediction 93 | 94 | eval.eval(next.getLabels(), output); // check the prediction against the true class 95 | } 96 | return eval; 97 | } 98 | 99 | private DataSetIterator normalize(DataSetIterator trainningDatas) { 100 | 101 | return NormalizeUtils.transform(trainningDatas); 102 | } 103 | 104 | public String toJson() { 105 | // TODO Auto-generated method stub 106 | return network.getLayerWiseConfigurations().toJson(); 107 | } 108 | 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/impl/network/SimpleBPNN.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.impl.network; 2 | 3 | import java.util.List; 4 | 5 | import org.aztec.dl4j.common.LayerConfiguration; 6 | import org.aztec.dl4j.common.NetworkConfiguration; 7 | import org.aztec.dl4j.common.impl.conf.SimpleNetworkConfiguration; 8 | import org.deeplearning4j.nn.api.OptimizationAlgorithm; 9 | import org.deeplearning4j.nn.conf.MultiLayerConfiguration; 10 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration; 11 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration.ListBuilder; 12 | import org.deeplearning4j.nn.conf.layers.DenseLayer; 13 | import org.deeplearning4j.nn.conf.layers.OutputLayer; 14 | import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; 15 | import org.deeplearning4j.optimize.listeners.ScoreIterationListener; 16 | import org.nd4j.linalg.activations.Activation; 17 | import org.nd4j.linalg.learning.config.Nesterovs; 18 | 19 | public class SimpleBPNN extends BaseNetwork{ 20 | 21 | 22 | public SimpleBPNN() { 23 | // TODO Auto-generated constructor stub 24 | } 25 | 26 | public void reset() { 27 | 28 | } 29 | 30 | public void doBuild(NetworkConfiguration rawConfig) { 31 | SimpleNetworkConfiguration networkConfig = rawConfig.adapt(SimpleNetworkConfiguration.class); 32 | networkBuilder = new NeuralNetConfiguration.Builder(); 33 | int layNum = networkConfig.getLayerNum(); 34 | ListBuilder listBuilder = networkBuilder.seed(networkConfig.getRngSeed()) //include a random seed for reproducibility 35 | // use stochastic gradient descent as an optimization algorithm 36 | .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT) 37 | .biasInit(networkConfig.getBias()) 38 | .updater(new Nesterovs(networkConfig.getLearningRatio(), networkConfig.getMomentum())) 39 | //.activation(Activation.ELU) 40 | .l1(networkConfig.getL1()) 41 | .l2(networkConfig.getL2()) 42 | .list(); 43 | 44 | List layerConfigs = networkConfig.getLayers(); 45 | for(int i = 0;i < layerConfigs.size();i++) { 46 | LayerConfiguration layerConfig = layerConfigs.get(i); 47 | switch(layerConfig.getType()) { 48 | case DENSE: 49 | listBuilder = listBuilder.layer(i,new DenseLayer.Builder() //create the first, input layer with xavier initialization 50 | .nIn(layerConfig.getInputNum()) 51 | .nOut(layerConfig.getOutputNum()) 52 | .biasInit(layerConfig.getBias()) 53 | .activation(layerConfig.getActiavtion()) 54 | .weightInit(layerConfig.getWeightInit()) 55 | .build()); 56 | break; 57 | case OUTPUT: 58 | listBuilder = listBuilder.layer(i,new OutputLayer.Builder(layerConfig.getLossFunction())//create the first, input layer with xavier initialization 59 | .nIn(layerConfig.getInputNum()) 60 | .nOut(layerConfig.getOutputNum()) 61 | .biasInit(layerConfig.getBias()) 62 | .activation(layerConfig.getActiavtion()) 63 | .weightInit(layerConfig.getWeightInit()) 64 | .build()); 65 | break; 66 | } 67 | 68 | } 69 | MultiLayerConfiguration mlc = listBuilder.pretrain(false).backprop(true).build(); 70 | network = new MultiLayerNetwork(mlc); 71 | 72 | network.init(); 73 | //print the score with every 1 iteration 74 | ScoreIterationListener sil = new ScoreIterationListener(); 75 | network.setListeners(sil); 76 | /* */ 77 | } 78 | 79 | 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/model/ball/BallTrainNetwork.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.model.ball; 2 | 3 | import org.aztec.dl4j.common.ArtificialNeuralNetworkException; 4 | import org.aztec.dl4j.common.NetworkConfiguration; 5 | import org.aztec.dl4j.common.impl.network.BaseNetwork; 6 | 7 | public class BallTrainNetwork extends BaseNetwork { 8 | 9 | //public static 10 | 11 | public BallTrainNetwork() { 12 | // TODO Auto-generated constructor stub 13 | } 14 | 15 | 16 | @Override 17 | protected void doBuild(NetworkConfiguration networkConfig) throws ArtificialNeuralNetworkException { 18 | // TODO Auto-generated method stub 19 | 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/model/ball/BallTrainningUtils.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.model.ball; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.aztec.dl4j.common.AritificialNerualNetworkFactory; 11 | import org.aztec.dl4j.common.ArtificialNeuralNetwork; 12 | import org.aztec.dl4j.common.impl.conf.SimpleNetworkConfiguration; 13 | import org.aztec.dl4j.common.impl.data.SimpleTensorIterator; 14 | import org.deeplearning4j.eval.Evaluation; 15 | import org.nd4j.linalg.activations.Activation; 16 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 17 | 18 | import com.clearspring.analytics.util.Lists; 19 | import com.google.common.collect.Maps; 20 | 21 | public class BallTrainningUtils { 22 | 23 | public BallTrainningUtils() { 24 | // TODO Auto-generated constructor stub 25 | } 26 | 27 | public static void testBPNN() { 28 | try { 29 | DataSetIterator dsi = getTrainningData( new File("test/ball/ball_bet_roll_data.csv"),new File("test/ball/ball_bet_match_result.csv")); 30 | int labelNum = 2; 31 | int featureNum = 13; 32 | SimpleNetworkConfiguration snc = new SimpleNetworkConfiguration(featureNum, labelNum); 33 | 34 | File saveFile = new File("test/ball/bp_save.dat"); 35 | 36 | snc.setNeuronNums(new int[] {300}); 37 | snc.setLayerNum(2); 38 | snc.setActivations(new Activation[] {Activation.LEAKYRELU,Activation.LEAKYRELU,Activation.SOFTMAX}); 39 | //snc.setBias(0.201); 40 | snc.setLearningRatio(0.05); 41 | //snc.setBiases(new double[] {0.08,0.088,1}); 42 | snc.setL1(0.1); 43 | snc.setL2(0.5); 44 | snc.setBiases(new double[] {0.87,0.005,0.005}); 45 | snc.setMomentum(0.01); 46 | snc.setNumEpochs(15000); 47 | ArtificialNeuralNetwork bpnn = AritificialNerualNetworkFactory.build(snc); 48 | 49 | long curTime = System.currentTimeMillis(); 50 | bpnn.train(dsi, snc.getNumEpochs(),false); 51 | long usedTime = System.currentTimeMillis() - curTime; 52 | System.out.println("Train use time:" + usedTime); 53 | 54 | //1295 5x 55 | Evaluation eval = bpnn.validate(dsi, labelNum,true); 56 | System.out.println(eval); 57 | //2596799,141 58 | double[] result = bpnn.predict(new double[] {144.5d,0.800d,0.800d,9d,135.5d,3d,6,0d,0d,0d,0d,0d,0d}); 59 | double[] result2 = bpnn.predict(new double[] {142.5d,0.800d,0.800d,6d,136.5d,0d,6d,0d,0d,0d,0d,0d,0d}); 60 | 61 | double[] result3 = bpnn.predict(new double[] {140.5d,0.800d,0.800d,13d,127.5d,5d,8d,0d,0d,0d,0d,0d,0d}); 62 | System.out.println("大:"+ result[0]); 63 | System.out.println("小:" + result[1]); 64 | System.out.println("2-大:"+ result2[0]); 65 | System.out.println("2-小:" + result2[1]); 66 | System.out.println("3-大:"+ result3[0]); 67 | System.out.println("3-小:" + result3[1]); 68 | //bpnn.predict(features) 69 | /*if(saveFile != null) { 70 | bpnn.save(saveFile); 71 | }*/ 72 | } catch (Exception e) { 73 | // TODO Auto-generated catch block 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | /*public static void testAutoBPNN(DataSetIterator dsi) { 79 | double[] ratioRanges = new double[] {0.5,0.6}; 80 | int[] neuronNumRanges = new int[] {1294,1296}; 81 | File workingDir = new File("test/arbiter"); 82 | long timeout = 100000; 83 | int maxCandidateNum = 1000; 84 | int batchSize = 50; 85 | int labelIndex = 0; 86 | int numEpochs = 50; 87 | int labelNum = 2; 88 | int inputNum = 13; 89 | try { 90 | Properties props = new Properties(); 91 | props.setProperty("minibatchSize", "" + batchSize); 92 | AutomaticNetwokConfiguration networkConfig = new AutomaticNetwokConfiguration( 93 | inputNum, labelNum, ratioRanges, neuronNumRanges, workingDir, timeout, maxCandidateNum, 94 | dsi); 95 | networkConfig.setBiasRanges(new double[] {0.8,0.9}); 96 | networkConfig.setLayerNum(2); 97 | ArtificialNeuralNetwork ann = AritificialNerualNetworkFactory.build(networkConfig); 98 | ann.train(dsi, labelNum, true); 99 | System.out.println(ann.validate((DataSetIterator)ds.testData(), labelNum, true)); 100 | } catch (Exception e) { 101 | // TODO Auto-generated catch block 102 | e.printStackTrace(); 103 | } 104 | }*/ 105 | 106 | public static void main(String[] args) { 107 | 108 | testBPNN(); 109 | } 110 | 111 | public static DataSetIterator getTrainningData(File rollInfoFile, File resultFile) throws IOException { 112 | 113 | Map matchResult = readMatchData(resultFile); 114 | BufferedReader br = new BufferedReader(new FileReader(rollInfoFile)); 115 | br.readLine(); 116 | List labelNames = Lists.newArrayList(); 117 | labelNames.add("b"); 118 | labelNames.add("s"); 119 | Object[] matchDatas = getOneMatchData(br, matchResult,null); 120 | SimpleTensorIterator tItr = null; 121 | while (matchDatas != null) { 122 | if (tItr == null) { 123 | tItr = new SimpleTensorIterator((List) matchDatas[0], (List) matchDatas[1], 124 | labelNames, Integer.MAX_VALUE); 125 | } 126 | else { 127 | tItr.appendDataSet((List) matchDatas[0], (List) matchDatas[1]); 128 | } 129 | if(matchDatas[3] == null) 130 | break; 131 | matchDatas = getOneMatchData(br, matchResult,(String) matchDatas[3]); 132 | } 133 | return tItr; 134 | } 135 | 136 | private static Object[] getOneMatchData(BufferedReader br, Map matchResult,String lastLine) throws IOException { 137 | String lineData = lastLine == null ? br.readLine() : lastLine; 138 | if (lineData == null) 139 | return null; 140 | List features = Lists.newArrayList(); 141 | List labels = Lists.newArrayList(); 142 | int recordCount = 0; 143 | String gid = null; 144 | while (lineData != null) { 145 | String[] rollDatas = lineData.split(","); 146 | if(gid == null) { 147 | gid = rollDatas[0]; 148 | } 149 | else if (!gid.equals(rollDatas[0])){ 150 | return new Object[] { features, labels, recordCount ,lineData}; 151 | } 152 | Double[] featureDatas = readFeature(rollDatas); 153 | features.add(featureDatas); 154 | labels.add(readLabel(gid, featureDatas[0], matchResult)); 155 | recordCount++; 156 | lineData = br.readLine(); 157 | } 158 | return new Object[] { features, labels, recordCount,null }; 159 | } 160 | 161 | private static Double[] readFeature(String[] rollDatas) { 162 | 163 | Double[] features = new Double[rollDatas.length - 1]; 164 | for (int i = 1; i < rollDatas.length; i++) { 165 | features[i - 1] = Double.parseDouble(rollDatas[i]); 166 | } 167 | return features; 168 | 169 | } 170 | 171 | private static Double[] readLabel(String gid, double valvePoint, Map resultDatas) { 172 | Double resultData = resultDatas.get(gid); 173 | return new Double[] { resultData > valvePoint ? 1d : 0d, resultData < valvePoint ? 1d : 0d }; 174 | //return new Double[] { 1.0d,0d }; 175 | } 176 | 177 | private static Map readMatchData(File resultFile) throws IOException { 178 | BufferedReader br = new BufferedReader(new FileReader(resultFile)); 179 | Map retList = Maps.newHashMap(); 180 | br.readLine(); 181 | String readLine = br.readLine(); 182 | while (readLine != null) { 183 | String[] lineDatas = readLine.split(","); 184 | retList.put(lineDatas[0], Double.parseDouble(lineDatas[1])); 185 | readLine = br.readLine(); 186 | } 187 | br.close(); 188 | return retList; 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/utils/NormalizeUtils.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.utils; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | import org.apache.commons.math3.stat.descriptive.moment.Mean; 6 | import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; 7 | import org.aztec.dl4j.common.impl.data.SimpleTensorIterator; 8 | import org.nd4j.linalg.api.ndarray.INDArray; 9 | import org.nd4j.linalg.dataset.DataSet; 10 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 11 | import org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize; 12 | import org.nd4j.linalg.factory.Nd4j; 13 | 14 | import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; 15 | 16 | public class NormalizeUtils { 17 | 18 | private NormalizeUtils() { 19 | } 20 | 21 | public static INDArray getMean(INDArray features) { 22 | int colNum = features.columns(); 23 | double[] means = new double[colNum]; 24 | for(int i = 0;i < colNum;i++) { 25 | double[] colDatas = features.getColumn(i).toDoubleVector(); 26 | Mean mean = new Mean(); 27 | means[i] = mean.evaluate(colDatas); 28 | } 29 | return Nd4j.create(means); 30 | } 31 | 32 | public static INDArray getStandardDeviation(INDArray features) { 33 | int colNum = features.columns(); 34 | double[] stds = new double[colNum]; 35 | for(int i = 0;i < colNum;i++) { 36 | double[] colDatas = features.getColumn(i).toDoubleVector(); 37 | StandardDeviation std = new StandardDeviation(); 38 | stds[i] = std.evaluate(colDatas); 39 | } 40 | return Nd4j.create(stds); 41 | } 42 | 43 | public static DataSetIterator transform(DataSetIterator itr) { 44 | NormalizerStandardize ns = new NormalizerStandardize(); 45 | //ns.fitLabel(true); 46 | ns.fit(itr); 47 | SimpleTensorIterator tensorIterator = new SimpleTensorIterator(); 48 | itr.reset(); 49 | while(itr.hasNext()) { 50 | DataSet ds = itr.next(); 51 | ns.transform(ds); 52 | tensorIterator.addDataSet(ds); 53 | } 54 | tensorIterator.reset(); 55 | return tensorIterator; 56 | } 57 | 58 | public double utf8toDouble(String text) throws UnsupportedEncodingException, Base64DecodingException { 59 | String base64 = StringUtils.utf8ToBase64(text); 60 | return new Double(base64.hashCode()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.utils; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; 6 | import com.sun.org.apache.xml.internal.security.utils.Base64; 7 | 8 | public class StringUtils { 9 | 10 | public StringUtils() { 11 | // TODO Auto-generated constructor stub 12 | } 13 | 14 | public static String utf8ToBase64(String utf8Text) throws UnsupportedEncodingException, Base64DecodingException { 15 | String base64Text = new String(utf8Text); 16 | return Base64.encode(utf8Text.getBytes("UTF-8")); 17 | } 18 | 19 | public static String base64ToUtf8(String base64Code) throws UnsupportedEncodingException, Base64DecodingException { 20 | String oriText = new String(Base64.decode(base64Code),"UTF-8"); 21 | return oriText; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/aztec/dl4j/common/utils/TrainningUtils.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl4j.common.utils; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.aztec.dl4j.common.impl.data.CSVDataFileInfo; 7 | import org.datavec.api.records.reader.RecordReader; 8 | import org.datavec.api.records.reader.impl.csv.CSVRecordReader; 9 | import org.datavec.api.split.FileSplit; 10 | import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; 11 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 12 | 13 | public class TrainningUtils { 14 | 15 | public TrainningUtils() { 16 | // TODO Auto-generated constructor stub 17 | } 18 | 19 | public static DataSetIterator csvToDataSet(CSVDataFileInfo fileInfo) 20 | throws IOException, InterruptedException { 21 | 22 | RecordReader rr = new CSVRecordReader(); 23 | rr.initialize(new FileSplit(fileInfo.getFile())); 24 | DataSetIterator dsi = new RecordReaderDataSetIterator(rr, fileInfo.getBatchSize(), fileInfo.getLabelIndex(), fileInfo.getLabelNums()); 25 | if(!fileInfo.isNormalized()) { 26 | dsi = NormalizeUtils.transform(dsi); 27 | } 28 | return dsi; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/aztec/dl_common/App.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl_common; 2 | 3 | import java.io.IOException; 4 | 5 | import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator; 6 | import org.deeplearning4j.eval.Evaluation; 7 | import org.deeplearning4j.nn.api.OptimizationAlgorithm; 8 | import org.deeplearning4j.nn.conf.MultiLayerConfiguration; 9 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration; 10 | import org.deeplearning4j.nn.conf.NeuralNetConfiguration.ListBuilder; 11 | import org.deeplearning4j.nn.conf.layers.DenseLayer; 12 | import org.deeplearning4j.nn.conf.layers.LossLayer; 13 | import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; 14 | import org.deeplearning4j.nn.weights.WeightInit; 15 | import org.deeplearning4j.optimize.listeners.ScoreIterationListener; 16 | import org.nd4j.linalg.activations.Activation; 17 | import org.nd4j.linalg.api.ndarray.INDArray; 18 | import org.nd4j.linalg.dataset.DataSet; 19 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 20 | import org.nd4j.linalg.factory.Nd4j; 21 | import org.nd4j.linalg.learning.config.Nesterovs; 22 | import org.nd4j.linalg.lossfunctions.LossFunctions.LossFunction; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * Hello world! 28 | * 29 | */ 30 | public class App { 31 | 32 | private static int seed = 100; 33 | private static int iterations = 100; 34 | private static int numRows = 100; 35 | private static int numColumns = 100; 36 | private static int outputNum = 100; 37 | 38 | private static Logger log = LoggerFactory.getLogger(App.class); 39 | 40 | public static void main(String[] args) { 41 | try { 42 | //autoencoderSample(); 43 | calculate(); 44 | } catch (Exception e) { 45 | // TODO Auto-generated catch block 46 | e.printStackTrace(); 47 | } 48 | 49 | } 50 | 51 | private static void calculate() { 52 | 53 | } 54 | 55 | 56 | private static void autoencoderSample() throws IOException { 57 | 58 | 59 | //number of rows and columns in the input pictures 60 | final int numRows = 28; 61 | final int numColumns = 28; 62 | int outputNum = 10; // number of output classes 63 | int batchSize = 128; // batch size for each epoch 64 | int rngSeed = 123; // random number seed for reproducibility 65 | int numEpochs = 15; // number of epochs to perform 66 | 67 | Nd4j.getRandom().setSeed(seed); 68 | //Get the DataSetIterators: 69 | DataSetIterator mnistTrain; 70 | DataSetIterator mnistTest; 71 | try { 72 | mnistTrain = new MnistDataSetIterator(batchSize, true, rngSeed); 73 | mnistTest = new MnistDataSetIterator(batchSize, false, rngSeed); 74 | 75 | Long curTime = System.currentTimeMillis(); 76 | System.out.println("build model.."); 77 | log.info("Build model...."); 78 | MultiLayerConfiguration conf = null; 79 | 80 | ListBuilder builder = new NeuralNetConfiguration.Builder() 81 | .seed(rngSeed) //include a random seed for reproducibility 82 | // use stochastic gradient descent as an optimization algorithm 83 | .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT) 84 | .updater(new Nesterovs(0.006, 0.9)) 85 | .l2(1e-4) 86 | .list(); 87 | builder = builder.layer(0, new DenseLayer.Builder() //create the first, input layer with xavier initialization 88 | .nIn(numRows * numColumns) 89 | .nOut(1000) 90 | //.nOut(outputNum) 91 | .activation(Activation.RELU) 92 | .weightInit(WeightInit.XAVIER) 93 | .build()); 94 | builder = builder.layer(1, new DenseLayer.Builder() //create hidden layer 95 | .nIn(1000) 96 | .nOut(10) 97 | .activation(Activation.RELU) 98 | .weightInit(WeightInit.XAVIER) 99 | .build()); 100 | builder = builder.layer(2,new LossLayer.Builder(LossFunction.NEGATIVELOGLIKELIHOOD) 101 | //.nIn(1000).nOut(outputNum) 102 | //.nIn(outputNum).nOut(outputNum) 103 | .activation(Activation.SOFTMAX) 104 | .weightInit(WeightInit.XAVIER) 105 | .build()); 106 | conf = builder.pretrain(false).backprop(true) //use backpropagation to adjust weights 107 | .build(); 108 | 109 | System.out.println("create layer.."); 110 | MultiLayerNetwork model = new MultiLayerNetwork(conf); 111 | model.init(); 112 | //print the score with every 1 iteration 113 | model.setListeners(new ScoreIterationListener(1)); 114 | 115 | //log.info("Train model...."); 116 | for( int i=0; i>>>>>>>>>:"); 138 | System.out.println(sampleData); 139 | System.out.println("sample>>>>>>>>>>:"); 140 | System.out.println(">>>>>>>>>>>>>>>>>>>>lables<<<<<<<<<<<<<<<<<<<<<<<<<<<"); 141 | System.out.println(next.getLabels()); 142 | 143 | System.out.println(">>>>>>>>>>>>>>>>>>>>lables<<<<<<<<<<<<<<<<<<<<<<<<<<<"); 144 | } 145 | 146 | System.out.println("Traing data............."); 147 | while(mnistTest.hasNext()){ 148 | DataSet next = mnistTest.next(); 149 | INDArray output = model.output(next.getFeatures()); //get the networks prediction 150 | 151 | //System.out.println("output:" + next); 152 | //System.out.println(">>>>>>>>>>>>>>>>>>>>lables<<<<<<<<<<<<<<<<<<<<<<<<<<<"); 153 | //System.out.println(next.getLabels()); 154 | 155 | //System.out.println(">>>>>>>>>>>>>>>>>>>>lables<<<<<<<<<<<<<<<<<<<<<<<<<<<"); 156 | //System.out.println(output); 157 | eval.eval(next.getLabels(), output); //check the prediction against the true class 158 | } 159 | log.info(eval.stats()); 160 | Long usedTime = System.currentTimeMillis() - curTime; 161 | System.out.println(eval.stats()); 162 | System.out.println("use time:" + usedTime); 163 | log.info("****************Example finished********************"); 164 | } catch (IOException e) { 165 | // TODO Auto-generated catch block 166 | e.printStackTrace(); 167 | } 168 | 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/test/java/org/aztec/dl_common/BP_NetworkTest.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl_common; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.RandomAccessFile; 6 | import java.nio.ByteBuffer; 7 | import java.nio.channels.FileChannel; 8 | import java.util.List; 9 | import java.util.Properties; 10 | import java.util.Random; 11 | 12 | import org.apache.commons.lang3.RandomUtils; 13 | import org.aztec.dl4j.common.AritificialNerualNetworkFactory; 14 | import org.aztec.dl4j.common.ArtificialNeuralNetwork; 15 | import org.aztec.dl4j.common.NetworkConfiguration; 16 | import org.aztec.dl4j.common.impl.conf.AutomaticNetwokConfiguration; 17 | import org.aztec.dl4j.common.impl.conf.SimpleNetworkConfiguration; 18 | import org.aztec.dl4j.common.impl.data.CSVDataFileInfo; 19 | import org.aztec.dl4j.common.impl.data.CSVDataSource; 20 | import org.aztec.dl4j.common.utils.TrainningUtils; 21 | import org.datavec.api.records.reader.RecordReader; 22 | import org.datavec.api.records.reader.impl.csv.CSVRecordReader; 23 | import org.datavec.api.split.FileSplit; 24 | import org.deeplearning4j.arbiter.optimize.api.data.DataSource; 25 | import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; 26 | import org.deeplearning4j.eval.Evaluation; 27 | import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; 28 | 29 | import com.google.common.collect.Lists; 30 | 31 | import junit.framework.TestCase; 32 | 33 | /** 34 | * BP网络测试类 35 | */ 36 | public class BP_NetworkTest 37 | extends TestCase{ 38 | 39 | private static final Random random = new Random(); 40 | private static final int inputNum = 5; 41 | private static final int labelNum = 5; 42 | private static File trainningFile = new File("test/csv/test_classfy_1.csv"); 43 | private static File testFile = new File("test/csv/test_classfy_2.csv"); 44 | 45 | public static void main(String[] args) { 46 | //generateData(); 47 | train(trainningFile,testFile,null); 48 | //testAutomaticBuildNetwork(); 49 | } 50 | 51 | private static void testAutomaticBuildNetwork() { 52 | 53 | double[] ratioRanges = new double[] {0.5,0.6}; 54 | int[] neuronNumRanges = new int[] {1294,1296}; 55 | File workingDir = new File("test/arbiter"); 56 | long timeout = 100000; 57 | int maxCandidateNum = 1000; 58 | int batchSize = 50; 59 | int labelIndex = 0; 60 | int numEpochs = 50; 61 | try { 62 | Properties props = new Properties(); 63 | props.setProperty("minibatchSize", "" + batchSize); 64 | DataSource ds = new CSVDataSource(new CSVDataFileInfo(trainningFile, batchSize, labelIndex, labelNum), 65 | new CSVDataFileInfo(testFile, batchSize, labelIndex, labelNum), props); 66 | AutomaticNetwokConfiguration networkConfig = new AutomaticNetwokConfiguration( 67 | inputNum, labelNum, ratioRanges, neuronNumRanges, workingDir, timeout, maxCandidateNum, 68 | ds); 69 | networkConfig.setBiasRanges(new double[] {0.8,0.9}); 70 | networkConfig.setLayerNum(2); 71 | ArtificialNeuralNetwork ann = AritificialNerualNetworkFactory.build(networkConfig); 72 | ann.train((DataSetIterator)ds.trainData(), labelNum, true); 73 | System.out.println(ann.validate((DataSetIterator)ds.testData(), labelNum, true)); 74 | } catch (Exception e) { 75 | // TODO Auto-generated catch block 76 | e.printStackTrace(); 77 | } 78 | 79 | } 80 | 81 | 82 | /** 83 | * 生成数据 84 | */ 85 | private static void generateData() { 86 | try { 87 | //testMain(args); 88 | File oldFile = new File("test/csv/test_classfy_1.csv"); 89 | oldFile.delete(); 90 | File newFile = new File("test/csv/test_classfy_2.csv"); 91 | newFile.delete(); 92 | generateCSVData(1000, oldFile); 93 | generateCSVData(1000, newFile); 94 | } catch (Exception e) { 95 | // TODO Auto-generated catch block 96 | e.printStackTrace(); 97 | } 98 | } 99 | 100 | /** 101 | * 读取csv文件数据,并训练网络 102 | * @param trainFile 103 | * @param testFile 104 | */ 105 | public static void train(File trainFile,File testFile,File saveFile) { 106 | try { 107 | int batchSize = 50; 108 | 109 | DataSetIterator trainIter = TrainningUtils.csvToDataSet(new CSVDataFileInfo(trainFile, batchSize, 0, labelNum)); 110 | DataSetIterator testIter = TrainningUtils.csvToDataSet(new CSVDataFileInfo(testFile, batchSize, 0, labelNum)); 111 | SimpleNetworkConfiguration snc = new SimpleNetworkConfiguration(inputNum, labelNum); 112 | 113 | snc.setNeuronNums(new int[] {1295}); 114 | snc.setLayerNum(1); 115 | //snc.setBias(0.201); 116 | snc.setLearningRatio(0.5792972893331771); 117 | //snc.setBiases(new double[] {0.08,0.088,1}); 118 | snc.setBiases(new double[] {0.8559749159474366,0.8559749159474366,0.8559749159474366}); 119 | snc.setMomentum(0.001); 120 | snc.setNumEpochs(150); 121 | ArtificialNeuralNetwork bpnn = AritificialNerualNetworkFactory.build(snc); 122 | if(saveFile != null && saveFile.exists()) { 123 | bpnn.load(saveFile); 124 | } 125 | else { 126 | long curTime = System.currentTimeMillis(); 127 | bpnn.train(trainIter, snc.getNumEpochs(),true); 128 | long usedTime = System.currentTimeMillis() - curTime; 129 | System.out.println("Train use time:" + usedTime); 130 | } 131 | //1295 5x 132 | Evaluation eval = bpnn.validate(testIter, labelNum,true); 133 | System.out.println(eval); 134 | if(saveFile != null) { 135 | bpnn.save(saveFile); 136 | } 137 | System.out.println(bpnn.toJson()); 138 | } catch (Exception e) { 139 | // TODO Auto-generated catch block 140 | e.printStackTrace(); 141 | } 142 | 143 | } 144 | 145 | /** 146 | * 生成csv文件数据 147 | * @param sampleSize 148 | * @param csvFile 149 | * @throws IOException 150 | */ 151 | private static void generateCSVData(int sampleSize,File csvFile) throws IOException { 152 | if(!csvFile.exists()) { 153 | csvFile.createNewFile(); 154 | } 155 | RandomAccessFile raf = new RandomAccessFile(csvFile, "rw"); 156 | FileChannel fc = raf.getChannel(); 157 | 158 | double[] peopleData = new double[] {}; 159 | for(int i = 0;i < sampleSize;i++) { 160 | int testNum = RandomUtils.nextInt() % labelNum; 161 | StringBuilder writeLine = new StringBuilder("" + testNum); 162 | switch(testNum) { 163 | case 0 : 164 | peopleData = generatePoorData(); 165 | break; 166 | case 1 : 167 | peopleData = generateWriteCollarData(); 168 | break; 169 | case 2 : 170 | peopleData = generateLeaderData(); 171 | //labels[0][i] = 2; 172 | break; 173 | case 3 : 174 | 175 | peopleData = generateRichData(); 176 | //labels[0][i] = 3; 177 | break; 178 | case 4 : 179 | 180 | peopleData = generateGoldenBachelorData(); 181 | //labels[0][i] = 4; 182 | break; 183 | } 184 | for(int j = 0;j < peopleData.length;j++) { 185 | writeLine.append("," + peopleData[j]); 186 | } 187 | writeLine.append("\n"); 188 | byte[] lineBytes = writeLine.toString().getBytes(); 189 | ByteBuffer bb = ByteBuffer.allocate(lineBytes.length); 190 | bb.put(lineBytes); 191 | bb.flip(); 192 | fc.write(bb); 193 | } 194 | fc.close(); 195 | } 196 | 197 | 198 | /** 199 | * 生成样品数据 200 | * @param sampleSize 201 | * @return 202 | */ 203 | private static List generateSampleData(int sampleSize){ 204 | 205 | List sampleAllDatas = Lists.newArrayList(); 206 | double[][] features = new double[sampleSize][]; 207 | double[][] labels = new double[sampleSize][]; 208 | //double[][] labels = new double[1][sampleSize]; 209 | for(int i = 0;i < sampleSize;i++) { 210 | int testNum = RandomUtils.nextInt() % 5; 211 | switch(testNum) { 212 | case 0 : 213 | features[i] = generatePoorData(); 214 | labels[i] = new double[]{1,0,0,0,0}; 215 | //labels[0][i] = 0; 216 | break; 217 | case 1 : 218 | 219 | features[i] = generateWriteCollarData(); 220 | labels[i] = new double[]{0,1,0,0,0}; 221 | //labels[0][i] = 1; 222 | break; 223 | case 2 : 224 | 225 | features[i] = generateLeaderData(); 226 | labels[i] = new double[]{0,0,1,0,0}; 227 | //labels[0][i] = 2; 228 | break; 229 | case 3 : 230 | 231 | features[i] = generateRichData(); 232 | labels[i] = new double[]{0,0,0,1,0}; 233 | //labels[0][i] = 3; 234 | break; 235 | case 4 : 236 | 237 | features[i] = generateGoldenBachelorData(); 238 | labels[i] = new double[]{0,0,0,0,1}; 239 | //labels[0][i] = 4; 240 | break; 241 | } 242 | 243 | } 244 | sampleAllDatas.add(features); 245 | sampleAllDatas.add(labels); 246 | return sampleAllDatas; 247 | 248 | } 249 | 250 | /** 251 | * 生成随机噪声 252 | * @param base 253 | * @return 254 | */ 255 | private static double getRandomNoise(double base) { 256 | double randomNum = random.nextDouble(); 257 | //return randomNum; 258 | return base * randomNum; 259 | //return 0; 260 | } 261 | 262 | 263 | /** 264 | * 生成吊丝数据 265 | * @param base 266 | * @return 267 | */ 268 | private static double[] generatePoorData() { 269 | //为了简化数据模样,提高训练速度,钱被简化成了一个倍数的概念。当然使用真实的人民币单位也可以,只是性能会差一点而已经 270 | double base = 5000; 271 | double deposit = base + getRandomNoise(10); 272 | double income = base + getRandomNoise(10); 273 | return new double[] {deposit,income,0d,0d,0d}; 274 | //return new double[] {deposit,income}; 275 | } 276 | 277 | 278 | /** 279 | * 生成白领数据 280 | * @return 281 | */ 282 | private static double[] generateWriteCollarData() { 283 | double base = 12000; 284 | double deposit = base + getRandomNoise(10); 285 | double hasChild = 0; 286 | double income = base + getRandomNoise(10); 287 | double hasHouse = random.nextDouble() > 0.5 ? 1 : 0; 288 | double hasCar = random.nextDouble() > 0.5 ? 1 : 0; 289 | return new double[] {deposit,income,hasHouse,hasCar,hasChild}; 290 | 291 | } 292 | 293 | /** 294 | * 生成高管数据 295 | * @return 296 | */ 297 | private static double[] generateLeaderData() { 298 | double base = 50000; 299 | double deposit = base + getRandomNoise(10); 300 | double income = base + getRandomNoise(10) ; 301 | return new double[] {deposit,income,1,1,1}; 302 | } 303 | 304 | /** 305 | * 生成有钱人数据 306 | * @return 307 | */ 308 | private static double[] generateRichData() { 309 | double base = 100000000; 310 | double deposit = base + getRandomNoise(10); 311 | double income = base + getRandomNoise(10); 312 | return new double[] {deposit,income,1,1,1}; 313 | } 314 | 315 | /** 316 | * 生成钻石王老五数据 317 | * @return 318 | */ 319 | private static double[] generateGoldenBachelorData() { 320 | double base = 100000000; 321 | double deposit = base + getRandomNoise(10); 322 | double income = base + getRandomNoise(10); 323 | return new double[] {deposit,income,1,1,0d}; 324 | } 325 | } 326 | -------------------------------------------------------------------------------- /src/test/java/org/aztec/dl_common/DirectHeapComparator.java: -------------------------------------------------------------------------------- 1 | package org.aztec.dl_common; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | import org.deeplearning4j.models.embeddings.learning.impl.elements.RandomUtils; 6 | 7 | public class DirectHeapComparator { 8 | 9 | public DirectHeapComparator() { 10 | 11 | 12 | } 13 | 14 | public static void main(String[] args) { 15 | int dataSize = 10 * 1024 * 1024; 16 | 17 | ByteBuffer heapBuffer = ByteBuffer.allocate(dataSize); 18 | heapBuffer.put(generateData(dataSize)); 19 | heapBuffer.flip(); 20 | ByteBuffer directBuffer = ByteBuffer.allocateDirect(dataSize); 21 | directBuffer.put(generateData(dataSize)); 22 | directBuffer.flip(); 23 | System.out.println("Heap buffer read time:" + testMemoryReadSpeed(heapBuffer)); 24 | System.out.println("direct buffer read time:" + testMemoryReadSpeed(directBuffer)); 25 | } 26 | 27 | private static byte[] generateData(int dataSize) { 28 | 29 | byte[] dataArray = new byte[dataSize]; 30 | for(int i = 0;i < dataArray.length;i++) { 31 | dataArray[i] = (byte) RandomUtils.nextInt(); 32 | } 33 | return dataArray; 34 | } 35 | 36 | private static long testMemoryReadSpeed(ByteBuffer buffer) { 37 | long curTime = System.currentTimeMillis(); 38 | while(buffer.hasRemaining()) { 39 | buffer.get(); 40 | } 41 | return System.currentTimeMillis() - curTime; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/arbiter/0/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/0/model.bin -------------------------------------------------------------------------------- /test/arbiter/0/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/0/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/1/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/1/model.bin -------------------------------------------------------------------------------- /test/arbiter/1/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/1/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/10/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/10/model.bin -------------------------------------------------------------------------------- /test/arbiter/10/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/10/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/11/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/11/model.bin -------------------------------------------------------------------------------- /test/arbiter/11/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/11/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/12/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/12/model.bin -------------------------------------------------------------------------------- /test/arbiter/12/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/12/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/13/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/13/model.bin -------------------------------------------------------------------------------- /test/arbiter/13/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/13/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/14/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/14/model.bin -------------------------------------------------------------------------------- /test/arbiter/14/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/14/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/15/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/15/model.bin -------------------------------------------------------------------------------- /test/arbiter/15/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/15/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/16/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/16/model.bin -------------------------------------------------------------------------------- /test/arbiter/16/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/16/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/17/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/17/model.bin -------------------------------------------------------------------------------- /test/arbiter/17/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/17/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/18/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/18/model.bin -------------------------------------------------------------------------------- /test/arbiter/18/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/18/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/19/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/19/model.bin -------------------------------------------------------------------------------- /test/arbiter/19/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/19/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/2/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/2/model.bin -------------------------------------------------------------------------------- /test/arbiter/2/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/2/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/20/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/20/model.bin -------------------------------------------------------------------------------- /test/arbiter/20/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/20/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/21/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/21/model.bin -------------------------------------------------------------------------------- /test/arbiter/21/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/21/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/22/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/22/model.bin -------------------------------------------------------------------------------- /test/arbiter/22/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/22/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/23/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/23/model.bin -------------------------------------------------------------------------------- /test/arbiter/23/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/23/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/24/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/24/model.bin -------------------------------------------------------------------------------- /test/arbiter/24/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/24/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/25/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/25/model.bin -------------------------------------------------------------------------------- /test/arbiter/25/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/25/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/26/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/26/model.bin -------------------------------------------------------------------------------- /test/arbiter/26/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/26/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/27/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/27/model.bin -------------------------------------------------------------------------------- /test/arbiter/27/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/27/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/28/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/28/model.bin -------------------------------------------------------------------------------- /test/arbiter/28/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/28/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/29/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/29/model.bin -------------------------------------------------------------------------------- /test/arbiter/29/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/29/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/3/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/3/model.bin -------------------------------------------------------------------------------- /test/arbiter/3/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/3/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/30/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/30/model.bin -------------------------------------------------------------------------------- /test/arbiter/30/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/30/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/31/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/31/model.bin -------------------------------------------------------------------------------- /test/arbiter/31/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/31/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/32/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/32/model.bin -------------------------------------------------------------------------------- /test/arbiter/32/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/32/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/33/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/33/model.bin -------------------------------------------------------------------------------- /test/arbiter/33/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/33/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/34/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/34/model.bin -------------------------------------------------------------------------------- /test/arbiter/34/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/34/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/35/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/35/model.bin -------------------------------------------------------------------------------- /test/arbiter/35/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/35/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/36/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/36/model.bin -------------------------------------------------------------------------------- /test/arbiter/36/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/36/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/37/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/37/model.bin -------------------------------------------------------------------------------- /test/arbiter/37/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/37/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/38/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/38/model.bin -------------------------------------------------------------------------------- /test/arbiter/38/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/38/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/39/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/39/model.bin -------------------------------------------------------------------------------- /test/arbiter/39/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/39/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/4/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/4/model.bin -------------------------------------------------------------------------------- /test/arbiter/4/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/4/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/40/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/40/model.bin -------------------------------------------------------------------------------- /test/arbiter/40/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/40/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/41/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/41/model.bin -------------------------------------------------------------------------------- /test/arbiter/41/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/41/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/42/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/42/model.bin -------------------------------------------------------------------------------- /test/arbiter/42/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/42/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/5/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/5/model.bin -------------------------------------------------------------------------------- /test/arbiter/5/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/5/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/6/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/6/model.bin -------------------------------------------------------------------------------- /test/arbiter/6/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/6/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/7/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/7/model.bin -------------------------------------------------------------------------------- /test/arbiter/7/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/7/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/8/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/8/model.bin -------------------------------------------------------------------------------- /test/arbiter/8/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/8/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/arbiter/9/model.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/arbiter/9/model.bin -------------------------------------------------------------------------------- /test/arbiter/9/numEpochs.txt: -------------------------------------------------------------------------------- 1 | 150 -------------------------------------------------------------------------------- /test/arbiter/9/score.txt: -------------------------------------------------------------------------------- 1 | 0.0 -------------------------------------------------------------------------------- /test/ball/ball_bet_match_result.csv: -------------------------------------------------------------------------------- 1 | gid,sc_total 2 | 2596855,170 3 | 2596876,156 4 | 2596799,141 5 | 2596813,181 6 | 2596897,154 7 | 2596960,128 8 | 2597569,164 9 | 2597709,186 10 | 2597674,173 11 | 2597730,155 12 | 2598066,193 13 | 2597940,147 14 | 2597898,138 15 | 2597919,129 16 | 2598108,181 17 | 2598129,179 18 | 2597982,167 19 | 2598003,178 20 | 2598773,179 21 | 2598794,181 22 | 2598815,176 23 | 2598710,145 24 | 2598836,172 25 | 2598983,186 26 | 2599067,167 27 | 2599088,168 28 | 2599193,149 29 | 2599151,173 30 | 2599403,164 31 | 2599445,183 32 | 2599466,165 33 | 2599235,135 34 | 2599361,170 35 | 2599529,162 36 | 2599543,166 37 | 2600201,149 38 | 2600243,159 39 | 2600936,186 40 | 2601020,132 41 | 2603379,178 42 | 2603400,156 43 | 2603547,172 44 | 2602434,154 45 | 2602455,155 46 | 2602476,173 47 | 2602539,180 48 | 2602749,149 49 | 2602581,158 50 | 2602602,166 51 | 2602644,165 52 | 2602392,162 53 | 2603274,167 54 | 2603295,183 55 | 2603358,171 56 | 2603617,153 57 | 2603638,158 58 | 2603701,183 59 | 2604954,151 60 | 2605038,172 61 | 2603876,166 62 | 2603897,157 63 | 2604044,171 64 | 2604107,210 65 | 2604128,165 66 | 2605584,154 67 | 2605731,194 68 | 2604149,156 69 | 2603981,148 70 | 2604170,157 71 | 2605752,140 72 | 2605143,169 73 | 2605164,173 74 | 2605185,167 75 | 2605794,166 76 | 2605815,175 77 | 2605836,178 78 | 2606739,165 79 | 2607831,210 80 | 2607901,174 81 | 2608006,189 82 | 2608027,194 83 | 2606928,147 84 | 2608069,185 85 | 2608741,198 86 | 2609266,194 87 | 2609602,154 88 | 2609665,145 89 | 2609686,178 90 | 2610218,161 91 | 2611737,151 92 | 2611506,170 93 | 2611422,206 94 | 2611443,159 95 | 2611968,162 96 | 2612325,208 97 | 2612346,177 98 | 2613235,170 99 | 2613298,200 100 | 2613676,204 101 | 2613739,231 102 | 2615825,177 103 | 2615160,166 104 | 2615202,175 105 | 2614929,246 106 | 2615244,194 107 | 2615265,177 108 | 2617883,185 109 | 2617988,160 110 | 2616889,170 111 | 2618030,251 112 | 2621180,154 113 | 2621201,192 114 | 2621222,187 115 | 2622335,159 116 | 2621558,185 117 | 2621579,158 118 | 2621978,232 119 | 2623434,169 120 | 2623350,170 121 | 2624407,178 122 | 2624176,234 123 | 2625226,268 124 | 2626640,170 125 | 2626262,245 126 | 2627102,188 127 | 2627249,239 128 | 2627270,241 129 | 2627396,232 130 | 2627522,166 131 | 2627543,169 132 | 2627165,191 133 | 2629762,198 134 | 2627438,233 135 | 2629076,209 136 | 2627732,181 137 | 2629139,171 138 | 2627900,183 139 | 2631043,167 140 | 2633213,161 141 | 2631883,170 142 | 2635467,186 143 | 2633290,225 144 | 2633311,220 145 | 2633374,243 146 | 2633416,238 147 | 2635488,167 148 | 2637259,168 149 | 2633493,235 150 | 2633514,225 151 | 2636538,199 152 | 2636559,191 153 | 2636118,207 154 | 2633598,254 155 | 2633619,248 156 | 2633640,278 157 | 2633661,214 158 | 2633682,219 159 | 2633724,247 160 | 2636790,169 161 | 2636811,157 162 | 2636832,174 163 | 2636853,176 164 | 2639436,156 165 | 2633766,230 166 | 2633829,234 167 | 2633850,225 168 | 2633913,229 169 | 2638421,203 170 | 2637812,230 171 | 2634018,227 172 | 2641480,233 173 | 2641501,237 174 | 2642838,211 175 | 2642964,240 176 | 2642131,265 177 | 2642173,238 178 | 2642425,213 179 | 2646268,197 180 | 2646478,184 181 | 2645995,162 182 | 2642551,241 183 | 2642614,247 184 | 2646562,170 185 | 2646709,197 186 | 2646247,164 187 | 2646520,164 188 | 2645953,164 189 | 2650153,243 190 | 2650279,213 191 | 2648830,188 192 | 2648032,173 193 | 2647234,202 194 | 2647255,224 195 | 2648221,234 196 | 2648326,240 197 | 2651098,192 198 | 2651161,192 199 | 2651847,229 200 | 2651868,219 201 | 2653184,220 202 | 2654864,261 203 | 2654885,230 204 | 2655893,207 205 | 2655851,193 206 | 2656019,224 207 | 2655557,169 208 | 2656523,183 209 | 2658833,216 210 | 2658854,256 211 | 2658875,234 212 | 2658938,226 213 | 2659946,253 214 | 2660009,227 215 | 2659547,165 216 | 2660177,212 217 | 2659022,167 218 | 2659169,162 219 | 2660408,155 220 | 2660324,163 221 | 2661185,222 222 | 2661206,235 223 | 2661598,233 224 | 2661619,212 225 | 2661640,205 226 | 2661703,229 227 | 2662039,197 228 | 2665567,219 229 | 2666540,225 230 | 2666582,245 231 | 2667107,175 232 | 2666708,238 233 | 2671426,186 234 | 2670691,282 235 | 2673148,194 236 | 2666750,238 237 | 2670439,167 238 | 2674387,169 239 | 2674408,192 240 | 2673631,273 241 | 2666981,218 242 | 2676074,238 243 | 2676011,180 244 | 2676977,188 245 | 2675969,158 246 | 2676221,237 247 | 2676137,233 248 | 2685244,227 249 | 2683270,171 250 | 2683312,178 251 | 2682787,248 252 | 2682871,228 253 | 2683333,239 254 | 2683375,220 255 | 2683438,216 256 | 2683459,253 257 | 2683480,227 258 | 2685118,173 259 | 2685139,172 260 | 2682913,168 261 | 2691208,178 262 | 2685503,171 263 | 2686868,246 264 | 2686910,247 265 | 2686973,241 266 | 2691173,196 267 | 2687057,221 268 | 2691110,154 269 | 2688506,187 270 | 2689514,163 271 | 2689913,228 272 | 2689346,161 273 | 2690711,173 274 | 2690942,190 275 | 2690984,168 276 | 2691026,187 277 | 2688674,272 278 | 2688716,219 279 | 2688758,250 280 | 2689871,248 281 | 2691481,233 282 | 2691502,229 283 | 2691523,246 284 | 2691586,266 285 | 2691334,178 286 | 2691271,163 287 | 2692531,164 288 | 2691460,211 289 | 2691607,228 290 | 2694407,167 291 | 2694428,179 292 | 2694365,161 293 | 2694449,171 294 | 2693483,188 295 | 2693042,249 296 | 2693105,233 297 | 2693147,234 298 | 2693063,223 299 | 2693672,243 300 | 2693714,232 301 | 2693000,170 302 | 2693420,175 303 | 2696927,154 304 | 2696948,196 305 | 2697095,183 306 | 2696759,204 307 | 2696780,201 308 | 2696843,181 309 | 2697074,182 310 | 2695772,175 311 | 2695898,241 312 | 2695940,226 313 | 2694743,238 314 | 2696045,250 315 | 2694764,199 316 | 2696003,239 317 | 2696066,243 318 | 2696129,207 319 | 2696150,229 320 | 2695121,140 321 | 2694659,231 322 | 2701673,177 323 | 2696108,232 324 | 2701694,173 325 | 2695919,236 326 | 2695961,232 327 | 2695709,167 328 | 2697599,189 329 | 2698187,181 330 | 2698208,171 331 | 2697662,252 332 | 2697851,133 333 | 2704816,157 334 | 2697746,188 335 | 2697725,174 336 | 2697767,171 337 | 2697809,177 338 | 2698453,191 339 | 2698516,204 340 | 2699461,219 341 | 2699482,223 342 | 2699797,167 343 | 2699881,185 344 | 2699902,163 345 | 2700007,170 346 | 2698936,171 347 | 2698558,207 348 | 2698999,196 349 | 2699020,153 350 | 2699041,172 351 | 2699314,165 352 | 2707147,143 353 | 2707168,166 354 | 2699818,176 355 | 2699755,222 356 | 2699524,233 357 | 2702723,145 358 | 2701862,180 359 | 2702492,187 360 | 2702513,169 361 | 2702618,167 362 | 2700028,225 363 | 2700133,217 364 | 2702282,159 365 | 2702303,155 366 | 2702324,165 367 | 2703024,171 368 | 2702261,169 369 | 2703150,179 370 | 2702639,154 371 | 2702660,166 372 | 2702877,175 373 | 2703213,156 374 | 2703171,170 375 | 2707273,228 376 | 2700154,264 377 | 2702072,176 378 | 2700091,238 379 | 2700112,233 380 | 2705761,175 381 | 2705782,163 382 | 2705971,169 383 | 2705950,135 384 | 2704879,177 385 | 2705803,184 386 | 2705908,175 387 | 2704921,179 388 | 2700196,225 389 | 2700217,247 390 | 2700280,240 391 | 2706874,169 392 | 2705068,158 393 | 2705110,155 394 | 2705173,159 395 | 2700238,252 396 | 2700301,245 397 | 2707924,170 398 | 2707882,165 399 | 2707861,200 400 | -------------------------------------------------------------------------------- /test/ball/bp_save.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uniqueleon/dl4j_common/d682728afdbf3cb28ec0d775e11f1de889ebeace/test/ball/bp_save.dat -------------------------------------------------------------------------------- /test/rnn/Cantonese.txt: -------------------------------------------------------------------------------- 1 | 你 老味 个 强奸犯 2 | 你好,我 是 一 碌 葛 3 | 大家 好,我 是 头盔 4 | 出去 威 记得 带 头盔 5 | 死人 强奸犯,烂坦 仔 6 | 你 个 死 烂坦 7 | 你 条 烂坦 8 | 恭祝 你 身体健康 9 | 我 有 单 野 要 同 你 讲 10 | 我 有 件 事 要 同 你 讲 11 | 哩 单 野 相当 麻烦 12 | 这 件 事 相当 麻烦 13 | 恭祝 你 全家富贵 14 | 你 食 左 饭 未 15 | 陷家产 16 | 扑街 17 | 死 人头 18 | 阿强 你 条 强奸犯,扑街 啦 你 19 | 你 老味,系 唔 系 打 得 少 20 | 关 你 卵 事 21 | 唔 好 甘 卵 串 22 | 串 我 的 人 都 死 得 好 卵 快 23 | 屎忽鬼 24 | 阴阳 贼 25 | 阴阳 屎忽鬼 26 | 请 不要 说 脏话, 谢谢 27 | 中国 人 必须 悍卫 自己 的 民族 尊严 28 | 早上 好 29 | 晚上 好 30 | 早安 31 | 晚安 32 | 吹 牛逼 33 | 看你 牛逼 哄哄的 34 | 就 你 那 吊样 35 | 搞 你妹 36 | 你 TMD 37 | 鸟人 38 | 你好 ,你 吃饭 了 没有 39 | 小样儿,别 跟 我 耍 花招 40 | 你好 ,请问 有 什么可 帮到 你 41 | 你好 ,请问有 乜 可 帮到 你 42 | 你 在 找什么呢 43 | 你 系度 稳 乜野 44 | 你 在 干 什么 45 | 你 搞 咩 野 46 | 有 什么 是 你 知道 的,我不知道 47 | 有 乜野 系 你 知,我 唔 知 48 | 你 TMD 在看什么 49 | 你 条 粉肠 系度 睇 乜 野 50 | 结帐 51 | 埋单 52 | 收帐 53 | 收数 54 | 打架 55 | 打交 56 | 单挑 57 | 只抽 58 | 老板 , 结帐 59 | 老板 , 埋单 60 | 有 事 慢慢 说, 不要 打架 61 | 有 野 慢慢 讲, 唔好 打交 62 | 明天 有 个 人 会 过来 收帐 63 | 听日 有 条 友 会 过来 收数 64 | 他 敢 过来 我 就 砍 他 TMD 65 | 距 敢 过来 我 就 劈 距 陷家产 66 | 你 有种 就 跟 我 单挑 67 | 你 够姜 就 同 我 只抽 68 | 有种 69 | 够姜 70 | 我 跟 你们 说 71 | 我 同 你地 讲 72 | 还手 73 | 还拖 74 | 动手 75 | 开拖 76 | 打 77 | 郁 78 | 我 打 你,你 居然 还 敢 还手 79 | 我 郁 你,你 居然 仲 敢 还拖 80 | 器张 81 | 串 82 | 你 这么 嚣张,信 不 信 我 打 你 83 | 你 甘 串,信 唔 信 我 郁 你 84 | 干掉 85 | 做瓜 86 | 你 信 不 信 我 干掉 你 87 | 你 信 唔 信 我 做瓜 你 88 | 拉倒 89 | 收皮 90 | 你 拉倒 吧 91 | 你 收皮 啦 92 | 你 信 唔 信 我 收 你 皮 93 | 帅哥 94 | 靓仔 95 | 呀!实在 太 帅 了,大人 的 帅 有如 滔滔江水 连绵不绝 地 涌过来 96 | 呀!实在 太 靓仔 啦,大人 既 英俊不凡 有如 滔滔江水 连绵不绝 甘 涌 埋 黎 97 | 小人 对 大人 的 钦敬 98 | 小人 对 大人 既 钦敬 99 | 大人,唱 得 唔好 唔驶 喊 100 | 大人,唱 得 不好 不用 哭 101 | 混 你 既 帐,我 系 伤心 而 喊,我 系 为 国家 为 人民 而 喊 102 | 混 你 的 帐,我 是 伤心 才 哭 的,我是 为 国家 为 人民 而 哭 103 | 初步 点算过,獒拜 既 总资产 系 三十八万两 104 | 初步 点算过,獒拜 的 总资产 为 三十八万两 105 | 獒振 呢个 狗贼,居然 落格 落 左 甘 多钱,我 呢世人 至憎 D 人 落格,我 一定 要 启奏 皇上 将 落格 既 人 五马分尸 106 | 獒拜 这个 狗贼,居然 贪污 贪 了 这么 多钱,我 这辈子 最恨 贪污 的 人,我 一定 要 启奏 皇上 将 贪污 的 人 五马分尸 107 | 卑职 小小 睇错,獒拜 既 总资产 系 三百八十万两 至真 108 | 卑职 小小 看错,獒拜 的 总资产 是 三百八十万两 才对 109 | 我 一定 要 再 启奏 皇上,要 距 恢复 明朝 对付 贪官 既 剥皮法,你 知 唔知 点 呀? 110 | 我 一定 要 再 启奏 皇上,要 他 恢复 明朝 对付 贪官 的 剥皮法, 你 知 不 知道 是 怎么样 的? 111 | 首先,将 你 个 人 埋系 D 沙 度,瓮住,突出 个 死人 头,再 稳 把 刀 系 头顶 汤 开,大 个 死人 窿,然后 将 D 水银 灌 落 个 伤口 度 112 | 首先,将你整个人埋在沙子里面,埋着,只留下个头在外面,再找把刀把头顶剖开,撑开那个洞,然后将水银灌进个伤口里面 113 | 你 当堂 成 个 人 痕 到 无法子 114 | 你 马上 整 个 人 都 痒 得 不行 115 | 无法子 又 点 呀 116 | 不行 又 怎么样 呀? 117 | 无法子 唔 稳 窿 捐,一见 头顶 有 个 窿,仲唔 连 层皮 都 唔要,啜声 捐 左 出 黎 118 | 不行 就 想 办法 找 洞 钻,一 看见 头顶 有 个 洞,还不 连 层皮 都 不要,一下 就 钻 了 出来 119 | 你 见 痕 唔见 呀 你 120 | 你 痒 不 痒 呀? 121 | 卑职 睇 清楚,獒拜 的 总资产 系 一千三百八十万 两,仲有 好多 系 无 记录,我 建议 全部 拎 上 去 大人 府 上,等 大人 点 清楚 至 呈 上去 122 | 卑职 看 清楚,獒拜 的 总资产 应该 是 一千三百八十万 两,还有 很多 是 没有 记录,我 建议 全部 拿 到 大人 府 上,等 大人 点 清楚 才 呈 上去 123 | 老老实实,我 稳 到 几多 同 你 五五分帐,唔驶 我 番入宫 得 唔 得 呀? 124 | 老老实实,我 赚 到 多少 和 你 五五分帐,不用 我 回宫 行 不 行 呀? 125 | 六四 都 有计倾 架 126 | 六四 都 可以 商量 的 127 | 想 七三 呀?大 贪 D 挂 128 | 想 七三 ?太 贪心 了 吧 129 | 唔通 你 想 八二 咩?你 都 算 无 人性 啦 130 | 难道 你 想 八二 呀?你 也 算 没 人性 啦 131 | 你 唔系 想 九一,系 甘 我 宁愿 番入宫 132 | 你 不会 想 九一,如果 是 这样,我 宁愿 回宫 133 | 小宝,你 系 个 聪明 人,我 就 可以 用 聪明 人 既 方式 同 你 讲野,而 出边 班 人 就 唔 可以 134 | 小宝,你 是 个 聪明 人,我 就 可以 用 聪明 人 的 方式 和 你 说话,而 外面 那 帮 人 就 不 可以 135 | 唔明 136 | 不懂 137 | 读 过 书 同 明 事理 既 人,大多 系 清廷 里面 做 紧 官,如果 我地 要 同 清廷 对抗,就 只能 用 一 D 蠢 D 既 人,对付 蠢 人,就 千祈 唔 能够 同 距地 讲 真 说话 138 | 读 过 书 和 明 事理 的 人,大多 在 清廷 里面 当 官,如果 我们 要 和 清廷 对抗,就 只能 用 一些 蠢 一 点 的 人,对付 蠢人,就 绝对 不 能够 跟 他们 说 真话 139 | 要 用 宗教 既 形式 黎 催眠 距地,等 距地 觉得 所做 既 野 都系 岩 既 140 | 要 用 宗教 的 形式 来 催眠 他们,等 他们 觉得 所做 的 事 都是 对 的 141 | 所以 反清复明 只系 一句 口号,同 阿弥陀佛 其实 系 一样 142 | 所以 反清复明 只是 一句 口号,同 阿弥陀佛 其实 是 一样 143 | 清朝 一直 欺压 我 地 汉人,抢 晒 我地 D 银两 同 女人,所以 我地 要 反清 144 | 清朝 一直 欺压 我们 汉人,抢 光 我们 的 银两 和 女人,所以 我们 要 反清 145 | 要 反清 黎 抢 番 D 钱 同 埋 D 女,根本 复 唔 复 明 就 多旧鱼,关人鬼事,大家聪明人,明白,继续 146 | 要 反清 来 抢 回 钱 和 女人,根本 复 不 复 明 就是 多余 的,关人屁事,大家 聪明人,了解,继续 147 | 总之 如果 你 成功 既 话,就 有 无数 既 银两 同 女人,甘 你 愿 唔 愿意 148 | 总之 如果 你 成功 的 话,就 有 无数 的 银两 和 女人,那 你 愿 不 愿意 149 | 愿意,但系你话九死一生,果 下 得人惊 吖嘛 150 | 愿意,但是 你 说 九死一生,那 太 吓人 了 151 | 我 可以 传 你 绝世武功 152 | 我 可以 传 你 绝世武功 153 | 咦,甘 大本,睇怕 练 都要 练 成个月 154 | 咦,这么大 的 一本,光 练 也要 练 一个月 155 | 哩 本 只 系 绝世武功 既 目录,果堆 先至 系 绝世武功 既 秘笈 156 | 这 本 只 是 练绝世武功 的 目录,那一堆 才是 绝世武功 的 秘笈 157 | 哇,睇 都 要 睇 成年 哦 158 | 哇,看 都 要 看 一 年 159 | 我 就 睇 左 三年,练 左 三十年 至 有 宜家 甘 既 境界 160 | 我 就 看 了 三看,练 了 三十 年 才 有 今天 的 境界 161 | 三十 年?我 有 几耐 时间 练 162 | 三十 年?我 有 多长 时间 可以 练 163 | 一晚 164 | 一晚 165 | 哦,甘 都 仲有 一晚 时间 练,甘 即系 九死一生 166 | 哦,还有 一晚 时间 练,那 还不是 九死一生 167 | 唔系 ,你 睇 左 就 九死一生,唔 睇 就 十死无生 168 | 不是 ,你 看 了 就 九死一生,不 看 就 十死无生 169 | 我地 捉 韦小宝 既 狗贼 先 170 | 我们 先 捉 韦小宝 这 个 狗贼 171 | 又 系 我 172 | 又 是 我 173 | 你 个 样 甘 无良 既,你 想 点 呀 你 174 | 你 的 样子 这么无良,你 想 怎样 175 | 喂,韦大人,你 唔系 甘 睇 我 下话,我 义气干云,对 你 既 景仰 有如 滔滔江水 都 连绵不绝 176 | 喂,韦大人,你 不会 这样子 看 我 吧,我 义气干云,你 对 的 景仰 有如 滔滔江水 都 连绵不绝 177 | 又 有如 黄河 泛滥,一发不可收拾 178 | 又 有如 黄河 泛滥,一发不可收拾 179 | 你个 死仔,你 仲好 讲,你 卖友求荣,无 义气 180 | 你 这个 混蛋, 你 还好意思 说,你 卖友求荣,没 义气 181 | 唔系 呢,韦大人,一 个 死 好过 两 个 死 呀,至少 有 我 同 你 拜山 吖嘛 182 | 不是 呀,韦大人,一 个 死 总 好过 两 个 死,至少 有 我 帮 你 扫墓 183 | 老友,你 要 既 人 我 帮 你 带 左 出黎 184 | 朋友,你 要 的 人 我 帮 你 带 出来 了 185 | 你 做乜 扮 女人 呀, 娜型 186 | 你 干嘛 装 女人,娘娘腔 187 | 大胆,见 到 我地 教主 仲 唔 下跪 188 | 大胆,看 到 我们 教主 还 不 下跪 189 | 做 左 教主 都 唔驶 扮 女人 者 190 | 做 了 教主 都 不用 装 女人 吧 191 | 哩个 先 系 我 既 庐山真面目 192 | 这个 才 是 我 的 庐山真面目 193 | 哦,你 家阵 好样 好 多,系 唔 系 好样 过 以前 呀,既然 大家 识 得 既,二口六面 讲 清楚 无事 啦,多隆,我地 走 咯 194 | 哦,你 现在 漂亮 很 多,是 不 是 比 以前 漂亮,既然 大家 认识,二口六面 说 清楚 就 没事 啦,多隆,我们 走 吧 195 | 先生,你 地 两 个 识,我 唔 识 你 既 哦 196 | 先生,你 们 两 个 认识,我 不 认识 你 的 197 | 哇,你 玩 到 甘 尽 198 | 哇,你 玩 得 太 过 了 吧 199 | 无 乜 特别 吖,教主,走 先 200 | 没 什么 特别,教主,我 先 走 了 -------------------------------------------------------------------------------- /test/rnn/RawText1.txt: -------------------------------------------------------------------------------- 1 | 你 老妹 个 强奸犯 2 | 你好,我 是 一碌 葛 3 | 大家 好,我 是 头盔 4 | 出去 威 记得 带 头盔 5 | 死人 强奸犯,烂坦 仔 6 | 你 个 死 烂坦 7 | 你 条 烂坦 8 | 恭祝 你 身体健康 9 | 我 有 件 事 要 同 你 讲 10 | 恭祝 你 全家富贵 11 | 恭喜 发财 12 | 发财 埋边 13 | 市场 销售 大量 上佳 粉 葛 14 | 作为 一碌 葛,你 责无旁贷 15 | 柑 蕉 桔 梨 萝 柚 16 | 雁 鹫 雕 狸 狮 狒 17 | 大雁 是 一种 飞鸟 18 | 柑桔 是 好吃 的 水果 19 | 香蕉 很 香,作为 水果 很 好吃 20 | 雪莉 有 清心润肺 的 作用 21 | 菠萝 即是 炸弹,会 BOMB BOMB 的 22 | 柚子 是 一种 好吃 的 水果 23 | 鹫 是 一种 凶猛 的 飞禽 24 | 雕 是 一种 厉害 的 飞禽 25 | 狮子 是 百兽之王 26 | 狒狒 是 灵长类 动物 27 | 何里活 有 间 大酒店 28 | 有 三 个 肥婆 学 踢波 29 | 你 又 踢 我 又 踢,卒之 距 踢左 落河 30 | 想 执番 个 波?我 帮 你 执个 波 31 | 我 标 落去 水面 双手 揽住 个 波 32 | fing 上去 水面 距 捉住 个 波 33 | 肥婆 只 鸡 甩 晒毛 34 | 比 肥佬 只 阴湿 狗 捉到 35 | 肥婆 实行 要 搏命 嘈 36 | 只 狗 要 稳 鸡 讲数 37 | 肥婆 只 鸡 死 猛嘈 38 | 比 服佬 只 阴湿 狗 捉到 39 | 肥婆 实行 要 肺痨 40 | 只 狗 要 稳 鸡 讲数 41 | 原来 只 狗 日日 呷 干嘈 42 | 肥婆 只 鸡 帮 狗 以前 有 路 43 | 肥婆 只 鸡 比 狗 带 绿帽 44 | 就算 系 人 都 估唔到 45 | 点解 我 系 甘长寿 46 | 日日 落 街边 抠斗 47 | 点解 我 系 甘 狼 48 | 系 乱 甘 辣 男人 定 老狗 49 | -------------------------------------------------------------------------------- /test/rnn/dialect/categories.txt: -------------------------------------------------------------------------------- 1 | 0,cantonese 2 | 1,mandarin -------------------------------------------------------------------------------- /test/rnn/dialect/test/0.txt: -------------------------------------------------------------------------------- 1 | 你 老味 个 强奸犯 2 | 你好,我 是 一 碌 葛 3 | 出去 威 记得 带 头盔 4 | 死人 强奸犯,烂坦 仔 5 | 你 个 死 烂坦 6 | 你 条 烂坦 7 | 我 有 单 野 要 同 你 讲 8 | 哩 单 野 相当 麻烦 9 | 这 件 事 相当 麻烦 10 | 恭祝 你 全家富贵 11 | 你 食 左 饭 未 12 | 阿强 你 条 强奸犯,扑街 啦 你 13 | 你 老味,系 唔 系 打 得 少 14 | 关 你 卵 事 15 | 唔 好 甘 卵 串 16 | 串 我 的 人 都 死 得 好 卵 快 17 | 屎忽鬼 18 | 阴阳 贼 19 | 阴阳 屎忽鬼 20 | 你好 ,请问有 乜 可 帮到 你 21 | 你 系度 稳 乜野 22 | 你 搞 咩 野 23 | 有 乜野 系 你 知,我 唔 知 24 | 你 条 粉肠 系度 睇 乜 野 25 | 老板 , 埋单 26 | 有 野 慢慢 讲, 唔好 打交 27 | 听日 有 条 友 会 过来 收数 28 | 距 敢 过来 我 就 劈 距 陷家产 29 | 你 够姜 就 同 我 只抽 30 | 我 郁 你,你 居然 仲 敢 还拖 31 | 你 甘 串,信 唔 信 我 郁 你 32 | 你 信 唔 信 我 做瓜 你 33 | 你 收皮 啦 34 | 你 信 唔 信 我 收 你 皮 35 | 呀!实在 太 靓仔 啦,大人 既 英俊不凡 有如 滔滔江水 连绵不绝 甘 涌 埋 黎 36 | 小人 对 大人 既 钦敬 37 | 大人,唱 得 唔好 唔驶 喊 38 | 混 你 既 帐,我 系 伤心 而 喊,我 系 为 国家 为 人民 而 喊 39 | 初步 点算过,獒拜 既 总资产 系 三十八万两 40 | 獒振 呢个 狗贼,居然 落格 落 左 甘 多钱,我 呢世人 至憎 D 人 落格,我 一定 要 启奏 皇上 将 落格 既 人 五马分尸 41 | 卑职 小小 睇错,獒拜 既 总资产 系 三百八十万两 至真 42 | 我 一定 要 再 启奏 皇上,要 距 恢复 明朝 对付 贪官 既 剥皮法,你 知 唔知 点 呀? 43 | 首先,将 你 个 人 埋系 D 沙 度,瓮住,突出 个 死人 头,再 稳 把 刀 系 头顶 汤 开,大 个 死人 窿,然后 将 D 水银 灌 落 个 伤口 度 44 | 你 当堂 成 个 人 痕 到 无法子 45 | 无法子 又 点 呀 46 | 无法子 唔 稳 窿 捐,一见 头顶 有 个 窿,仲唔 连 层皮 都 唔要,啜声 捐 左 出 黎 47 | 你 见 痕 唔见 呀 你 48 | 卑职 睇 清楚,獒拜 的 总资产 系 一千三百八十万 两,仲有 好多 系 无 记录,我 建议 全部 拎 上 去 大人 府 上,等 大人 点 清楚 至 呈 上去 49 | 甘 你 即系 明 稳 两 个 人 黎 监 视 我 者 50 | 老老实实,我 稳 到 几多 同 你 五五 分帐,唔驶 我 番入宫 得 唔 得 呀? 51 | 六四 都 有计倾 架 52 | 想 七三 呀?大 贪 D 挂 53 | 唔通 你 想 八二 咩?你 都 算 无 人性 啦 54 | 你 唔系 想 九一,系 甘 我 宁愿 番入宫 55 | 小宝,你 系 个 聪明 人,我 就 可以 用 聪明 人 既 方式 同 你 讲野,而 出边 班 人 就 唔 可以 56 | 唔明 57 | 读 过 书 同 明 事理 既 人,大多 系 清廷 里面 做 紧 官,如果 我地 要 同 清廷 对抗,就 只能 用 一 D 蠢 D 既 人,对付 蠢 人,就 千祈 唔 能够 同 距地 讲 真 说话 58 | 要 用 宗教 既 形式 黎 催眠 距地,等 距地 觉得 所做 既 野 都系 岩 既 59 | 所以 反清复明 只系 一句 口号,同 阿弥陀佛 其实 系 一样 60 | 清朝 一直 欺压 我 地 汉人,抢 晒 我地 D 银两 同 女人,所以 我地 要 反清 61 | 要 反清 黎 抢 番 D 钱 同 埋 D 女,根本 复 唔 复 明 就 多旧鱼,关人鬼事,大家聪明人,明白,继续 62 | 总之 如果 你 成功 既 话,就 有 无数 既 银两 同 女人,甘 你 愿 唔 愿意 63 | 愿意,但系你话九死一生,果 下 得人惊 吖嘛 64 | 我 可以 传 你 绝世武功 65 | 咦,甘 大本,睇怕 练 都要 练 成个月 66 | 哩 本 只 系 绝世武功 既 目录,果堆 先至 系 绝世武功 既 秘笈 67 | 哇,睇 都 要 睇 成年 哦 68 | 我 就 睇 左 三年,练 左 三十年 至 有 宜家 甘 既 境界 69 | 三十年?我 有 几耐 时间 练 70 | 一晚 71 | 哦,甘 都 仲有 一晚 时间 练,甘 即系 九死一生 72 | 唔系 ,你 睇 左 就 九死一生,唔 睇 就 十死无生 73 | 我地 捉 韦小宝 既 狗贼 先 74 | 又 系 我 75 | 你 个 样 甘 无良 既,你 想 点 呀 你 76 | 喂,韦大人,你 唔系 甘 睇 我 下话,我 义气干云,对 你 既 景仰 有如 滔滔江水 都 连绵不绝 77 | 又 有如 黄河 泛滥,一发不可收拾 78 | 你个 死仔,你 仲好 讲,你 卖友求荣,无 义气 79 | 唔系 呢,韦大人,一 个 死 好过 两 个 死 呀,至少 有 我 同 你 拜山 吖嘛 80 | 老友,你 要 既 人 我 帮 你 带 左 出黎 81 | 你 做乜 扮 女人 呀, 娜型 82 | 大胆,见 到 我地 教主 仲 唔 下跪 83 | 做 左 教主 都 唔驶 扮 女人 者 84 | 哩个 先 系 我 既 庐山真面目 85 | 哦,你 家阵 好样 好 多,系 唔 系 好样 过 以前 呀,既然 大家 识 得 既,二口六面 讲 清楚 无事 啦,多隆,我地 走 咯 86 | 先生,你 地 两 个 识,我 唔 识 你 既 哦 87 | 哇,你 玩 到 甘 尽 88 | 无 乜 特别 吖,教主,走 先 -------------------------------------------------------------------------------- /test/rnn/dialect/test/1.txt: -------------------------------------------------------------------------------- 1 | 恭祝 你 身体健康 2 | 我 有 件 事 要 跟 你 讲 3 | 恭祝 你 全家富贵 4 | 请 不要 说 脏话, 谢谢 5 | 中国 人 必须 悍卫 自己 的 民族 尊严 6 | 晚上 好 7 | 早上 好 8 | 晚上 好 9 | 早安 10 | 晚安 11 | 吹 牛逼 12 | 看你 牛逼 哄哄的 13 | 就 你 那 吊样 14 | 操 你妹 15 | 你 TMD 16 | 你好 ,你 吃饭 了 没有 17 | 小样儿,别 跟 我 耍 花招 18 | 你好 ,请问 有 什么可 帮到 你 19 | 你 在 找什么呢 20 | 你 在 干 什么 21 | 有 什么 是 你 知道 的,我不知道 22 | 你 TMD 在看什么 23 | 老板 , 结帐 24 | 有 事 慢慢 说, 不要 打架 25 | 我 打 你,你 居然 还 敢 还手 26 | 明天 有 个 人 会 过来 收帐 27 | 你 有种 就 跟 我 单挑 28 | 你 这么 嚣张,信 不 信 我 打 你 29 | 你 信 不 信 我 干掉 你 30 | 你 拉倒 吧 31 | 呀!实在 太 帅 了,大人 的 帅 有如 滔滔江水 连绵不绝 地 涌过来 32 | 小人 对 大人 的 钦敬 33 | 大人,唱 得 不好 不用 哭 34 | 初步 点算过,獒拜 的 总资产 为 三十八万两 35 | 獒拜 这个 狗贼,居然 贪污 贪 了 这么 多钱,我 这辈子 最恨 贪污 的 人,我 一定 要 启奏 皇上 将 贪污 的 人 五马分尸 36 | 卑职 小小 看错,獒拜 的 总资产 是 三百八十万两 才对 37 | 我 一定 要 再 启奏 皇上,要 他 恢复 明朝 对付 贪官 的 剥皮法, 你 知 不 知道 是 怎么样 的? 38 | 首先,将你整个人埋在沙子里面,埋着,只留下个头在外面,再找把刀把头顶剖开,撑开那个洞,然后将水银灌进伤口里面 39 | 你 马上 整 个 人 痒 得 不行 40 | 不行 又 怎么样 呀? 41 | 不行 就 想 办法 找 洞 钻,一 看见 头顶 有 个 洞,还不 连 层皮 都 不要,一下 就 钻 了 出来 42 | 你 痒 不 痒 呀? 43 | 卑职 看 清楚,獒拜 的 总资产 应该 是 一千三百八十万 两,还有 很多 是 没有 记录,我 建议 全部 拿 到 大人 府 上,等 大人 点 清楚 才 呈 上去 44 | 老老实实,我 赚 到 多少 和 你 五五分帐,不用 我 回宫 行 不 行 呀? 45 | 六四 都 可以 商量 的 46 | 想 七三 ?太 贪心 了 吧 47 | 难道 你 想 八二 呀?你 也 算 没 人性 啦 48 | 你 不会 想 九一,如果 是 这样,我 宁愿 回宫 49 | 小宝,你 是 个 聪明 人,我 就 可以 用 聪明 人 的 方式 和 你 说话,而 外面 那 帮 人 就 不 可以 50 | 不懂 51 | 读 过 书 和 明 事理 的 人,大多 在 清廷 里面 当 官,如果 我们 要 和 清廷 对抗,就 只能 用 一些 蠢 一 点 的 人,对付 蠢人,就 绝对 不 能够 跟 他们 说 真话 52 | 要 用 宗教 的 形式 来 催眠 他们,等 他们 觉得 所做 的 事 都是 对 的 53 | 所以 反清复明 只是 一句 口号,同 阿弥陀佛 其实 是 一样 54 | 清朝 一直 欺压 我们 汉人,抢 光 我们 的 银两 和 女人,所以 我们 要 反清 55 | 要 反清 来 抢 回 钱 和 女人,根本 复 不 复 明 就是 多余 的,关人屁事,大家 聪明人,了解,继续 56 | 总之 如果 你 成功 的 话,就 有 无数 的 银两 和 女人,那 你 愿 不 愿意 57 | 愿意,但是 你 说 九死一生,那 太 吓人 了 58 | 我 可以 传 你 绝世武功 59 | 咦,这么大 的 一本,光 练 也要 练 一个月 60 | 这 本 只 是 练绝世武功 的 目录,那一堆 才是 绝世武功 的 秘笈 61 | 哇,看 都 要 看 一 年 62 | 我 就 看 了 三看,练 了 三十 年 才 有 今天 的 境界 63 | 三十年?我 有 多长 时间 可以 练 64 | 一晚 65 | 哦,还有 一晚 时间 练,那 还不是 九死一生 66 | 不是 ,你 看 了 就 九死一生,不 看 就 十死无生 67 | 我们 先 捉 韦小宝 这 个 狗贼 68 | 又 是 我 69 | 你 的 样子 这么无良,你 想 怎样 70 | 喂,韦大人,你 不会 这样子 看 我 吧,我 义气干云,你 对 的 景仰 有如 滔滔江水 都 连绵不绝 71 | 又 有如 黄河 泛滥,一发不可收拾 72 | 你 这个 混蛋, 你 还好意思 说,你 卖友求荣,没 义气 73 | 不是 呀,韦大人,一 个 死 总 好过 两 个 死,至少 有 我 帮 你 扫墓 74 | 朋友,你 要 的 人 我 帮 你 带 出来 了 75 | 你 干嘛 装 女人,娘娘腔 76 | 大胆,看 到 我们 教主 还 不 下跪 77 | 做 了 教主 都 不用 装 女人 吧 78 | 这个 才 是 我 的 庐山真面目 79 | 哦,你 现在 漂亮 很 多,是 不 是 比 以前 漂亮,既然 大家 认识,二口六面 说 清楚 就 没事 啦,多隆,我们 走 吧 80 | 先生,你 们 两 个 认识,我 不 认识 你 的 81 | 哇,你 玩 得 太 过 了 吧 82 | 没 什么 特别,教主,我 先 走 了 -------------------------------------------------------------------------------- /test/rnn/dialect/train/0.txt: -------------------------------------------------------------------------------- 1 | 你 老味 个 强奸犯 2 | 你好,我 是 一 碌 葛 3 | 出去 威 记得 带 头盔 4 | 死人 强奸犯,烂坦 仔 5 | 你 个 死 烂坦 6 | 你 条 烂坦 7 | 我 有 单 野 要 同 你 讲 8 | 哩 单 野 相当 麻烦 9 | 这 件 事 相当 麻烦 10 | 恭祝 你 全家富贵 11 | 你 食 左 饭 未 12 | 阿强 你 条 强奸犯,扑街 啦 你 13 | 你 老味,系 唔 系 打 得 少 14 | 关 你 卵 事 15 | 唔 好 甘 卵 串 16 | 串 我 的 人 都 死 得 好 卵 快 17 | 屎忽鬼 18 | 阴阳 贼 19 | 阴阳 屎忽鬼 20 | 你好 ,请问有 乜 可 帮到 你 21 | 你 系度 稳 乜野 22 | 你 搞 咩 野 23 | 有 乜野 系 你 知,我 唔 知 24 | 你 条 粉肠 系度 睇 乜 野 25 | 老板 , 埋单 26 | 有 野 慢慢 讲, 唔好 打交 27 | 听日 有 条 友 会 过来 收数 28 | 距 敢 过来 我 就 劈 距 陷家产 29 | 你 够姜 就 同 我 只抽 30 | 我 郁 你,你 居然 仲 敢 还拖 31 | 你 甘 串,信 唔 信 我 郁 你 32 | 你 信 唔 信 我 做瓜 你 33 | 你 收皮 啦 34 | 你 信 唔 信 我 收 你 皮 35 | 呀!实在 太 靓仔 啦,大人 既 英俊不凡 有如 滔滔江水 连绵不绝 甘 涌 埋 黎 36 | 小人 对 大人 既 钦敬 37 | 大人,唱 得 唔好 唔驶 喊 38 | 混 你 既 帐,我 系 伤心 而 喊,我 系 为 国家 为 人民 而 喊 39 | 初步 点算过,獒拜 既 总资产 系 三十八万两 40 | 獒振 呢个 狗贼,居然 落格 落 左 甘 多钱,我 呢世人 至憎 D 人 落格,我 一定 要 启奏 皇上 将 落格 既 人 五马分尸 41 | 卑职 小小 睇错,獒拜 既 总资产 系 三百八十万两 至真 42 | 我 一定 要 再 启奏 皇上,要 距 恢复 明朝 对付 贪官 既 剥皮法,你 知 唔知 点 呀? 43 | 首先,将 你 个 人 埋系 D 沙 度,瓮住,突出 个 死人 头,再 稳 把 刀 系 头顶 汤 开,大 个 死人 窿,然后 将 D 水银 灌 落 个 伤口 度 44 | 你 当堂 成 个 人 痕 到 无法子 45 | 无法子 又 点 呀 46 | 无法子 唔 稳 窿 捐,一见 头顶 有 个 窿,仲唔 连 层皮 都 唔要,啜声 捐 左 出 黎 47 | 你 见 痕 唔见 呀 你 48 | 卑职 睇 清楚,獒拜 的 总资产 系 一千三百八十万 两,仲有 好多 系 无 记录,我 建议 全部 拎 上 去 大人 府 上,等 大人 点 清楚 至 呈 上去 49 | 甘 你 即系 明 稳 两 个 人 黎 监 视 我 者 50 | 老老实实,我 稳 到 几多 同 你 五五 分帐,唔驶 我 番入宫 得 唔 得 呀? 51 | 六四 都 有计倾 架 52 | 想 七三 呀?大 贪 D 挂 53 | 唔通 你 想 八二 咩?你 都 算 无 人性 啦 54 | 你 唔系 想 九一,系 甘 我 宁愿 番入宫 55 | 小宝,你 系 个 聪明 人,我 就 可以 用 聪明 人 既 方式 同 你 讲野,而 出边 班 人 就 唔 可以 56 | 唔明 57 | 读 过 书 同 明 事理 既 人,大多 系 清廷 里面 做 紧 官,如果 我地 要 同 清廷 对抗,就 只能 用 一 D 蠢 D 既 人,对付 蠢 人,就 千祈 唔 能够 同 距地 讲 真 说话 58 | 要 用 宗教 既 形式 黎 催眠 距地,等 距地 觉得 所做 既 野 都系 岩 既 59 | 所以 反清复明 只系 一句 口号,同 阿弥陀佛 其实 系 一样 60 | 清朝 一直 欺压 我 地 汉人,抢 晒 我地 D 银两 同 女人,所以 我地 要 反清 61 | 要 反清 黎 抢 番 D 钱 同 埋 D 女,根本 复 唔 复 明 就 多旧鱼,关人鬼事,大家聪明人,明白,继续 62 | 总之 如果 你 成功 既 话,就 有 无数 既 银两 同 女人,甘 你 愿 唔 愿意 63 | 愿意,但系你话九死一生,果 下 得人惊 吖嘛 64 | 我 可以 传 你 绝世武功 65 | 咦,甘 大本,睇怕 练 都要 练 成个月 66 | 哩 本 只 系 绝世武功 既 目录,果堆 先至 系 绝世武功 既 秘笈 67 | 哇,睇 都 要 睇 成年 哦 68 | 我 就 睇 左 三年,练 左 三十年 至 有 宜家 甘 既 境界 69 | 三十年?我 有 几耐 时间 练 70 | 一晚 71 | 哦,甘 都 仲有 一晚 时间 练,甘 即系 九死一生 72 | 唔系 ,你 睇 左 就 九死一生,唔 睇 就 十死无生 73 | 我地 捉 韦小宝 既 狗贼 先 74 | 又 系 我 75 | 你 个 样 甘 无良 既,你 想 点 呀 你 76 | 喂,韦大人,你 唔系 甘 睇 我 下话,我 义气干云,对 你 既 景仰 有如 滔滔江水 都 连绵不绝 77 | 又 有如 黄河 泛滥,一发不可收拾 78 | 你个 死仔,你 仲好 讲,你 卖友求荣,无 义气 79 | 唔系 呢,韦大人,一 个 死 好过 两 个 死 呀,至少 有 我 同 你 拜山 吖嘛 80 | 老友,你 要 既 人 我 帮 你 带 左 出黎 81 | 你 做乜 扮 女人 呀, 娜型 82 | 大胆,见 到 我地 教主 仲 唔 下跪 83 | 做 左 教主 都 唔驶 扮 女人 者 84 | 哩个 先 系 我 既 庐山真面目 85 | 哦,你 家阵 好样 好 多,系 唔 系 好样 过 以前 呀,既然 大家 识 得 既,二口六面 讲 清楚 无事 啦,多隆,我地 走 咯 86 | 先生,你 地 两 个 识,我 唔 识 你 既 哦 87 | 哇,你 玩 到 甘 尽 88 | 无 乜 特别 吖,教主,走 先 -------------------------------------------------------------------------------- /test/rnn/dialect/train/1.txt: -------------------------------------------------------------------------------- 1 | 恭祝 你 身体健康 2 | 我 有 件 事 要 跟 你 讲 3 | 恭祝 你 全家富贵 4 | 请 不要 说 脏话, 谢谢 5 | 中国 人 必须 悍卫 自己 的 民族 尊严 6 | 晚上 好 7 | 早上 好 8 | 晚上 好 9 | 早安 10 | 晚安 11 | 吹 牛逼 12 | 看你 牛逼 哄哄的 13 | 就 你 那 吊样 14 | 操 你妹 15 | 你 TMD 16 | 你好 ,你 吃饭 了 没有 17 | 小样儿,别 跟 我 耍 花招 18 | 你好 ,请问 有 什么可 帮到 你 19 | 你 在 找什么呢 20 | 你 在 干 什么 21 | 有 什么 是 你 知道 的,我不知道 22 | 你 TMD 在看什么 23 | 老板 , 结帐 24 | 有 事 慢慢 说, 不要 打架 25 | 我 打 你,你 居然 还 敢 还手 26 | 明天 有 个 人 会 过来 收帐 27 | 你 有种 就 跟 我 单挑 28 | 你 这么 嚣张,信 不 信 我 打 你 29 | 你 信 不 信 我 干掉 你 30 | 你 拉倒 吧 31 | 呀!实在 太 帅 了,大人 的 帅 有如 滔滔江水 连绵不绝 地 涌过来 32 | 小人 对 大人 的 钦敬 33 | 大人,唱 得 不好 不用 哭 34 | 初步 点算过,獒拜 的 总资产 为 三十八万两 35 | 獒拜 这个 狗贼,居然 贪污 贪 了 这么 多钱,我 这辈子 最恨 贪污 的 人,我 一定 要 启奏 皇上 将 贪污 的 人 五马分尸 36 | 卑职 小小 看错,獒拜 的 总资产 是 三百八十万两 才对 37 | 我 一定 要 再 启奏 皇上,要 他 恢复 明朝 对付 贪官 的 剥皮法, 你 知 不 知道 是 怎么样 的? 38 | 首先,将你整个人埋在沙子里面,埋着,只留下个头在外面,再找把刀把头顶剖开,撑开那个洞,然后将水银灌进伤口里面 39 | 你 马上 整 个 人 痒 得 不行 40 | 不行 又 怎么样 呀? 41 | 不行 就 想 办法 找 洞 钻,一 看见 头顶 有 个 洞,还不 连 层皮 都 不要,一下 就 钻 了 出来 42 | 你 痒 不 痒 呀? 43 | 卑职 看 清楚,獒拜 的 总资产 应该 是 一千三百八十万 两,还有 很多 是 没有 记录,我 建议 全部 拿 到 大人 府 上,等 大人 点 清楚 才 呈 上去 44 | 老老实实,我 赚 到 多少 和 你 五五分帐,不用 我 回宫 行 不 行 呀? 45 | 六四 都 可以 商量 的 46 | 想 七三 ?太 贪心 了 吧 47 | 难道 你 想 八二 呀?你 也 算 没 人性 啦 48 | 你 不会 想 九一,如果 是 这样,我 宁愿 回宫 49 | 小宝,你 是 个 聪明 人,我 就 可以 用 聪明 人 的 方式 和 你 说话,而 外面 那 帮 人 就 不 可以 50 | 不懂 51 | 读 过 书 和 明 事理 的 人,大多 在 清廷 里面 当 官,如果 我们 要 和 清廷 对抗,就 只能 用 一些 蠢 一 点 的 人,对付 蠢人,就 绝对 不 能够 跟 他们 说 真话 52 | 要 用 宗教 的 形式 来 催眠 他们,等 他们 觉得 所做 的 事 都是 对 的 53 | 所以 反清复明 只是 一句 口号,同 阿弥陀佛 其实 是 一样 54 | 清朝 一直 欺压 我们 汉人,抢 光 我们 的 银两 和 女人,所以 我们 要 反清 55 | 要 反清 来 抢 回 钱 和 女人,根本 复 不 复 明 就是 多余 的,关人屁事,大家 聪明人,了解,继续 56 | 总之 如果 你 成功 的 话,就 有 无数 的 银两 和 女人,那 你 愿 不 愿意 57 | 愿意,但是 你 说 九死一生,那 太 吓人 了 58 | 我 可以 传 你 绝世武功 59 | 咦,这么大 的 一本,光 练 也要 练 一个月 60 | 这 本 只 是 练绝世武功 的 目录,那一堆 才是 绝世武功 的 秘笈 61 | 哇,看 都 要 看 一 年 62 | 我 就 看 了 三看,练 了 三十 年 才 有 今天 的 境界 63 | 三十年?我 有 多长 时间 可以 练 64 | 一晚 65 | 哦,还有 一晚 时间 练,那 还不是 九死一生 66 | 不是 ,你 看 了 就 九死一生,不 看 就 十死无生 67 | 我们 先 捉 韦小宝 这 个 狗贼 68 | 又 是 我 69 | 你 的 样子 这么无良,你 想 怎样 70 | 喂,韦大人,你 不会 这样子 看 我 吧,我 义气干云,你 对 的 景仰 有如 滔滔江水 都 连绵不绝 71 | 又 有如 黄河 泛滥,一发不可收拾 72 | 你 这个 混蛋, 你 还好意思 说,你 卖友求荣,没 义气 73 | 不是 呀,韦大人,一 个 死 总 好过 两 个 死,至少 有 我 帮 你 扫墓 74 | 朋友,你 要 的 人 我 帮 你 带 出来 了 75 | 你 干嘛 装 女人,娘娘腔 76 | 大胆,看 到 我们 教主 还 不 下跪 77 | 做 了 教主 都 不用 装 女人 吧 78 | 这个 才 是 我 的 庐山真面目 79 | 哦,你 现在 漂亮 很 多,是 不 是 比 以前 漂亮,既然 大家 认识,二口六面 说 清楚 就 没事 啦,多隆,我们 走 吧 80 | 先生,你 们 两 个 认识,我 不 认识 你 的 81 | 哇,你 玩 得 太 过 了 吧 82 | 没 什么 特别,教主,我 先 走 了 --------------------------------------------------------------------------------