/* * * -----> BUTTONS CLICK <----- * */ private void modifyRssSourceButton_Click(object sender, EventArgs e) { if (rssSourcesGridView.SelectedRows.Count == 0) { MetroMessageBox.Show(this, "Para eliminar primero debe seleccionar una fuente RSS de la lista", "No hay ninguna fuente RSS seleccionada", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //se hace depp copy para evitar que el formulario de fuente RSS modifique el objeto antes de guardarlo var rssSourceForm = new RssSourceForm( DeepCopyHelper.DeepCopy <RssSourceDTO>((RssSourceDTO)rssSourcesGridView.SelectedRows[0].DataBoundItem) ); StyleManager.Clone(rssSourceForm); if (rssSourceForm.ShowDialog(this) == DialogResult.OK) { //modificar la fuente RSS try { iRssSourceService.Update(rssSourceForm.iRssSourceModel); MetroMessageBox.Show(this, "se han modificado todos los datos", "Exito al modificar la fuente RSS", MessageBoxButtons.OK, MessageBoxIcon.Question); reloadSearch(); } catch (Exception ex) { MetroMessageBox.Show(this, "detalles del error: " + ex.Message, "Error al modificar la fuente RSS", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
static double Evaluate(FunctionStack model, int[] dataset) { FunctionStack predictModel = DeepCopyHelper.DeepCopy(model); predictModel.ResetState(); Real totalLoss = 0; long totalLossCount = 0; for (int i = 0; i < dataset.Length - 1; i++) { NdArray x = new NdArray(new[] { 1 }, BATCH_SIZE); NdArray t = new NdArray(new[] { 1 }, BATCH_SIZE); for (int j = 0; j < BATCH_SIZE; j++) { x.Data[j] = dataset[j + i]; t.Data[j] = dataset[j + i + 1]; } Real sumLoss = new SoftmaxCrossEntropy().Evaluate(predictModel.Forward(x), t); totalLoss += sumLoss; totalLossCount++; } //calc perplexity return(Math.Exp(totalLoss / (totalLossCount - 1))); }
private void modifyImageButton_Click(object sender, EventArgs e) { if (imagesGridView.SelectedRows.Count == 0) { MetroMessageBox.Show(this, "Para modificar primero debe seleccionar una imagen de la lista", "No hay ninguna imagen seleccionada", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var imageForm = new ImageForm( DeepCopyHelper.DeepCopy <ImageDTO>((ImageDTO)imagesGridView.SelectedRows[0].DataBoundItem), getImageListLength() ); StyleManager.Clone(imageForm); if (imageForm.ShowDialog(this) == DialogResult.OK) { var updatedImage = imageForm.iImageModel; var oldImage = iCampaignModel.Images.Where(i => i.Id == updatedImage.Id).First(); //checkear que no ocupe el orden que ya tenia otra imagen if (updatedImage.Order != oldImage.Order) { var solapedImage = iCampaignModel.Images.Where(image => image.Order == updatedImage.Order).First(); solapedImage.Order = oldImage.Order; } iCampaignModel.Images[iCampaignModel.Images.IndexOf(oldImage)] = updatedImage; refreshImagesGridView(); } }
static Real Evaluate(FunctionStack <Real> model, int[] dataset) { FunctionStack <Real> predictModel = DeepCopyHelper <Real> .DeepCopy(model); predictModel.ResetState(); Real totalLoss = 0; long totalLossCount = 0; for (int i = 0; i < dataset.Length - 1; i++) { NdArray <Real> x = new NdArray <Real>(new[] { 1 }, BATCH_SIZE); NdArray <int> t = new NdArray <int>(new[] { 1 }, BATCH_SIZE); for (int j = 0; j < BATCH_SIZE; j++) { x.Data[j] = dataset[j + i]; t.Data[j] = dataset[j + i + 1]; } NdArray <Real> result = predictModel.Forward(x)[0]; Real sumLoss = new SoftmaxCrossEntropy <Real>().Evaluate(result, t); totalLoss += sumLoss; totalLossCount++; } //calc perplexity return(Math.Exp(totalLoss / (totalLossCount - 1))); }
//コピーを作成するメソッド public Function Clone() { return(DeepCopyHelper.DeepCopy(this)); }
public static object DeepCopy(this object originalObject) { return(DeepCopyHelper.DeepCopy(originalObject, new Dictionary <object, object>(new DeepCopyReferenceEqualityComparer()))); }
public NetworkLayer Clone() { return(DeepCopyHelper.DeepCopy(this)); }