Exemple #1
0
 public void Matrix_WeightAdd_EX_Full(CudaPieceFloat gpu_floats_a, CudaPieceFloat gpu_floats_b, CudaPieceInt inver_neg_index,
                                      CudaPieceInt inver_neg_value, int nTrial, int BATCHSIZE, int batchsize, int dimension, CudaPieceFloat mweight,
                                      int start, int keep)
 {
     BasicMathlib.Matrix_WeightAdd_EX_Full(gpu_floats_a.MemPtr, gpu_floats_b.MemPtr, inver_neg_index.MemPtr,
                                           inver_neg_value.MemPtr, nTrial, BATCHSIZE, batchsize, dimension, mweight.MemPtr, start, keep);
 }
Exemple #2
0
 public BatchSample_Input(int MAX_BATCH_SIZE, int MAXSEQUENCE_PERBATCH, int MAXELEMENTS_PERBATCH)
 {
     sample_Idx = new CudaPieceInt(MAX_BATCH_SIZE, true, true);
     seg_Idx    = new CudaPieceInt(MAXSEQUENCE_PERBATCH, true, true);
     seg_Margin = new CudaPieceInt(MAXSEQUENCE_PERBATCH, true, true);
     seg_Len    = new CudaPieceFloat(MAXSEQUENCE_PERBATCH, true, true);
     fea_Idx    = new CudaPieceInt(MAXELEMENTS_PERBATCH, true, true);
     fea_Value  = new CudaPieceFloat(MAXELEMENTS_PERBATCH, true, true);
 }
Exemple #3
0
        public NeuralLinkData(NeuralLink neuralLink)
        {
            neuralLinkModel = neuralLink;

            if (neuralLinkModel.Nt == N_Type.Convolution_layer)
            {
                layerPoolingOutput = new CudaPieceFloat(PairInputStream.MAXSEGMENT_BATCH * neuralLinkModel.Neural_Out.Number, false, true);

                layerMaxPooling_Index = new CudaPieceInt(ParameterSetting.BATCH_SIZE * neuralLinkModel.Neural_Out.Number, false, true);
            }

            weightDeriv = new CudaPieceFloat(neuralLinkModel.Neural_In.Number * neuralLinkModel.Neural_Out.Number * neuralLinkModel.N_Winsize, false, true);
            biasDeriv   = new CudaPieceFloat(neuralLinkModel.Neural_Out.Number, false, true);

            weightUpdate = new CudaPieceFloat(neuralLinkModel.Neural_In.Number * neuralLinkModel.Neural_Out.Number * neuralLinkModel.N_Winsize, false, true);
            biasUpdate   = new CudaPieceFloat(neuralLinkModel.Neural_Out.Number, false, true);
        }
Exemple #4
0
        void Init(DNN dnn_query, DNN dnn_doc)
        {
            dnn_model_query = new DNNRun(dnn_query);
            dnn_model_doc   = new DNNRun(dnn_doc);

            Pos_QD_Pair_TOP = new Layer_Output_Deriv_QD_PairTOP(dnn_query, dnn_doc);
            Neg_QD_Pair_TOP = new Layer_Output_Deriv_QD_PairTOP_Full(dnn_query, dnn_doc, ParameterSetting.NTRIAL);

            alphaCudaPiece = new CudaPieceFloat(ParameterSetting.BATCH_SIZE * (ParameterSetting.NTRIAL + 1), true, true);
            distCudaPiece  = new CudaPieceFloat(ParameterSetting.BATCH_SIZE * (ParameterSetting.NTRIAL + 1), true, true);

            GPU_negative_index_Array       = new CudaPieceInt(ParameterSetting.NTRIAL * ParameterSetting.BATCH_SIZE, true, true);
            GPU_Inver_negative_index_Array = new CudaPieceInt(ParameterSetting.NTRIAL * ParameterSetting.BATCH_SIZE, true, true);
            GPU_Inver_negative_value_Array = new CudaPieceInt(ParameterSetting.NTRIAL * ParameterSetting.BATCH_SIZE, true, true);

            if (ParameterSetting.PSEUDO_RANDOM)
            {
                neg_random = new Random(ParameterSetting.RANDOM_SEED);
            }
        }
Exemple #5
0
 public void Convolution_Sparse_Matrix_Product_INTEX(CudaPieceFloat upperOutputErrorDeriv, CudaPieceInt layerMaxPooling_Index, BatchSample_Input input_batch, int winSize, int batchsize, int outputDimension, CudaPieceFloat weightDeriv, int inputDimension)
 {
     BasicMathlib.Convolution_Sparse_Matrix_Product_INTEX(upperOutputErrorDeriv.MemPtr, layerMaxPooling_Index.MemPtr, input_batch.Seg_Idx_Mem, input_batch.Seg_Margin_Mem, input_batch.segsize, winSize,
                                                          batchsize, outputDimension, input_batch.Fea_Idx_Mem, input_batch.Fea_Value_Mem, weightDeriv.MemPtr, inputDimension);
 }
Exemple #6
0
 public void Matrix_WeightAdd_EX(CudaPieceFloat result, CudaPieceFloat addTerm, CudaPieceInt GPU_Inver_negative_index, CudaPieceInt GPU_Inver_negative_value, int batchsize, int outputLayerSize, CudaPieceFloat mweight, int start, int keep)
 {
     BasicMathlib.Matrix_WeightAdd_EX(result.MemPtr, addTerm.MemPtr, GPU_Inver_negative_index.MemPtr, GPU_Inver_negative_value.MemPtr, batchsize, outputLayerSize, mweight.MemPtr, start, keep);
 }
Exemple #7
0
 public void Derive_Cosine_Rectified_EX(CudaPieceFloat srcTopLayerOutput, CudaPieceFloat tgtTopLayerOutput, CudaPieceInt GPU_negative_index, CudaPieceFloat srcTopLayerOutputDeriv, CudaPieceFloat tgtTopLayerOutputDeriv, int batchsize, int outputLayerSize, float eps)
 {
     BasicMathlib.Derive_Cosine_Rectified_EX(srcTopLayerOutput.MemPtr, tgtTopLayerOutput.MemPtr, GPU_negative_index.MemPtr, srcTopLayerOutputDeriv.MemPtr, tgtTopLayerOutputDeriv.MemPtr, batchsize, outputLayerSize, eps);
 }
Exemple #8
0
 public void FillOut_Dist_NCE(CudaPieceFloat dist, CudaPieceInt GPU_negative_index, int nTrailPlus1, int BATCH_SIZE, int mIndex, int batchsize)
 {
     BasicMathlib.FillOut_Dist_NCE(dist.MemPtr, GPU_negative_index.MemPtr, nTrailPlus1, BATCH_SIZE, mIndex, batchsize);
 }
Exemple #9
0
 public void Cosine_Similarity_EX(CudaPieceFloat srcTopLayerOutput, CudaPieceFloat tgtTopLayerOutput, CudaPieceInt GPU_negative_index, CudaPieceFloat alpha, int nTrailPlus1, int BATCH_SIZE, int mIndex, int batchsize, int topLayerSize, float eps)
 {
     BasicMathlib.Cosine_Similarity_EX(srcTopLayerOutput.MemPtr,
                                       tgtTopLayerOutput.MemPtr, GPU_negative_index.MemPtr, alpha.MemPtr, nTrailPlus1, BATCH_SIZE, mIndex,
                                       batchsize, topLayerSize, eps);
 }
Exemple #10
0
 public void Max_Pooling(CudaPieceFloat layerPoolingOutput, BatchSample_Input data, CudaPieceFloat output, CudaPieceInt layerMaxPooling_Index, int outputDimension)
 {
     BasicMathlib.Max_Pooling(layerPoolingOutput.MemPtr, data.Sample_Idx_Mem, data.batchsize, output.MemPtr, layerMaxPooling_Index.MemPtr, outputDimension);
 }
Exemple #11
0
 public void Deriv_Cosine_Rectified_EX_Full(CudaPieceFloat q, CudaPieceFloat d, CudaPieceInt neg_list, CudaPieceFloat dcq, CudaPieceFloat dcd,
                                            int nTrail, int BATCHSIZE, int batchsize, int m, float eps)
 {
     BasicMathlib.Deriv_Cosine_Rectified_EX_Full(q.MemPtr, d.MemPtr, neg_list.MemPtr, dcq.MemPtr, dcd.MemPtr, nTrail, BATCHSIZE, batchsize, m, eps);
 }
Exemple #12
0
 public void FillOut_Dist_NCE_Full(CudaPieceFloat dist, CudaPieceInt neg_list, int nTrail, int BATCH_SIZE, int batchsize)
 {
     BasicMathlib.FillOut_Dist_NCE_Full(dist.MemPtr, neg_list.MemPtr, nTrail, BATCH_SIZE, batchsize);
 }
Exemple #13
0
 public void Cosine_Similarity_EX_Full(CudaPieceFloat a, CudaPieceFloat b, CudaPieceInt neg_list, CudaPieceFloat c, int nTrial, int BATCHSIZE,
                                       int batchsize, int dimension, float eps)
 {
     BasicMathlib.Cosine_Similarity_EX_Full(a.MemPtr, b.MemPtr, neg_list.MemPtr, c.MemPtr, nTrial, BATCHSIZE, batchsize, dimension, eps);
 }
Exemple #14
0
 public void Deriv_Cosine_Linear_EX_Full(CudaPieceFloat q, CudaPieceFloat d, CudaPieceInt neg_list, CudaPieceFloat dcq, CudaPieceFloat dcd,
                                         int nTrail, int BATCHSIZE, int batchsize, int m, float eps)
 {
     Cudalib.Deriv_Cosine_Linear_EX_Full(q.CudaPtr, d.CudaPtr, neg_list.CudaPtr, dcq.CudaPtr, dcd.CudaPtr, nTrail, BATCHSIZE, batchsize, m, eps);
 }
Exemple #15
0
 public void Derive_Cosine_Linear_EX(CudaPieceFloat srcTopLayerOutput, CudaPieceFloat tgtTopLayerOutput, CudaPieceInt GPU_negative_index, CudaPieceFloat srcTopLayerOutputDeriv, CudaPieceFloat tgtTopLayerOutputDeriv, int batchsize, int outputLayerSize, float eps)
 {
     Cudalib.Derive_Cosine_Linear_EX(srcTopLayerOutput.CudaPtr, tgtTopLayerOutput.CudaPtr, GPU_negative_index.CudaPtr, srcTopLayerOutputDeriv.CudaPtr, tgtTopLayerOutputDeriv.CudaPtr, batchsize, outputLayerSize, eps);
 }