Skip to content

Commit 4f28e79

Browse files
committed
add Upgrade_20201230_TensorFlow
1 parent f377362 commit 4f28e79

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

Signum.Upgrade/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static void Main(string[] args)
4040
new Upgrade_20201210_NavigatorView(),
4141
new Upgrade_20201220_React17(),
4242
new Upgrade_20201223_IndexErrorHandling(),
43+
new Upgrade_20201230_TensorFlow(),
4344
}.Run(uctx);
4445
}
4546
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using Signum.Utilities;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Security.Cryptography.X509Certificates;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Signum.Upgrade.Upgrades
11+
{
12+
class Upgrade_20201230_TensorFlow : CodeUpgradeBase
13+
{
14+
public override string Description => "replace CNTK for TensorFlow";
15+
16+
public override void Execute(UpgradeContext uctx)
17+
{
18+
uctx.ChangeCodeFile(@".gitignore", file =>
19+
{
20+
file.InsertAfterLastLine(
21+
a=>a.Contains("ts_out"),
22+
@"/Southwind.React/TensorFlowModels/**");
23+
});
24+
25+
uctx.ChangeCodeFile(@"Southwind.Logic/Southwind.Logic.csproj", file =>
26+
{
27+
file.Replace(
28+
@"Signum.Engine.MachineLearning.CNTK\Signum.Engine.MachineLearning.CNTK.csproj",
29+
@"Signum.Engine.MachineLearning.TensorFlow\Signum.Engine.MachineLearning.TensorFlow.csproj");
30+
31+
});
32+
33+
uctx.ChangeCodeFile(@"Southwind.React/Southwind.React.csproj", file =>
34+
{
35+
file.ReplaceLine(a => a.Contains("CNTK.CPUOnly"),
36+
@"<PackageReference Include=""SciSharp.TensorFlow.Redist"" Version=""2.3.1"" />"
37+
);
38+
});
39+
40+
uctx.ChangeCodeFile(@"Southwind.Logic/Starter.cs", file =>
41+
{
42+
file.Replace(
43+
@"using Signum.Engine.MachineLearning.CNTK;",
44+
@"using Signum.Engine.MachineLearning.TensorFlow;");
45+
46+
file.Replace(
47+
@"CNTKPredictorAlgorithm.NeuralNetwork, new CNTKNeuralNetworkPredictorAlgorithm()",
48+
@"TensorFlowPredictorAlgorithm.NeuralNetworkGraph, new TensorFlowNeuralNetworkPredictor()");
49+
50+
});
51+
52+
uctx.ChangeCodeFile(@"Southwind.Terminal/SouthwindMigrations.cs", file =>
53+
{
54+
file.Replace(
55+
@"CNTKPredictorAlgorithm.NeuralNetwork",
56+
@"TensorFlowPredictorAlgorithm.NeuralNetworkGraph");
57+
58+
file.Replace(
59+
@"Learner = NeuralNetworkLearner.MomentumSGD",
60+
@"Optimizer = TensorFlowOptimizer.GradientDescentOptimizer");
61+
62+
file.Replace(
63+
@"LossFunction = NeuralNetworkEvalFunction.SquaredError",
64+
@"LossFunction = NeuralNetworkEvalFunction.MeanSquaredError");
65+
66+
file.ReplaceBetweenIncluded(
67+
a => a.Contains("LearningRate = 0.1,"),
68+
a => a.Contains("LearningUnitGain = false,"),
69+
@"LearningRate = 0.0001,");
70+
});
71+
72+
uctx.ChangeCodeFile(@"*.csproj", file =>
73+
{
74+
file.RemoveAllLines(a => a.Contains("<Platforms>"));
75+
file.ReplaceBetweenIncluded(
76+
a => a.Contains("<PropertyGroup Condition="),
77+
a => a.Contains("</PropertyGroup>"),
78+
"");
79+
});
80+
81+
uctx.ChangeCodeFile(@"Southwind.sln", file =>
82+
{
83+
file.Replace("x64", "Any CPU");
84+
});
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)