unsafe public void calculate_deltaQD_TOP(Layer_Output_Deriv_QD_PairTOP output, int batchsize) { if (dnn_model_query.neurallinks.Last().NeuralLinkModel.Af == A_Func.Tanh) { MathOperatorManager.GlobalInstance.Deriv_Cosine(dnn_model_query.neurallayers.Last().Output, dnn_model_doc.neurallayers.Last().Output, output.cuda_layer_Deriv_Q, output.cuda_layer_Deriv_D, batchsize, dnn_model_query.OutputLayerSize, ParameterSetting.DSSMEpsilon); } else if (dnn_model_query.neurallinks.Last().NeuralLinkModel.Af == A_Func.Linear) { MathOperatorManager.GlobalInstance.Derive_Cosine_Linear(dnn_model_query.neurallayers.Last().Output, dnn_model_doc.neurallayers.Last().Output, output.cuda_layer_Deriv_Q, output.cuda_layer_Deriv_D, batchsize, dnn_model_query.OutputLayerSize, ParameterSetting.DSSMEpsilon); } }
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); } }