| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6726cbd commit e2f7be6
100 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,11 +26,11 @@ In comparison to other projects, like for instance TensorFlowSharp which only pr | |||
| 26 | 26 | ||
| 27 | 27 | ### How to use | |
| 28 | 28 | ||
| 29 | - | TensorFlow | tf 1.13 | tf 1.14 | tf 1.15 | tf 2.2 | | ||
| 30 | - | ----------- | ------- | ------- | ------- | ------ | | ||
| 31 | - | tf.net 0.20 | | | x | x | | ||
| 32 | - | tf.net 0.15 | | x | x | | | ||
| 33 | - | tf.net 0.14 | x | x | | | | ||
| 29 | + | TensorFlow | tf native1.14 | tf native 1.15 | tf native 2.3 | | ||
| 30 | + | ----------- | ------------- | -------------- | ------------- | | ||
| 31 | + | tf.net 0.20 | | x | x | | ||
| 32 | + | tf.net 0.15 | x | x | | | ||
| 33 | + | tf.net 0.14 | x | | | | ||
| 34 | 34 | ||
| 35 | 35 | Install TF.NET and TensorFlow binary through NuGet. | |
| 36 | 36 | ```sh | |
@@ -138,6 +138,10 @@ Scan QR code to join Tencent TIM group: | |||
| 138 | 138 | ||
| 139 | 139 |  | |
| 140 | 140 | ||
| 141 | + WeChat Sponsor 微信打赏: | ||
| 142 | + | ||
| 143 | +  | ||
| 144 | + | ||
| 141 | 145 | TensorFlow.NET is a part of [SciSharp STACK](https://scisharp.github.io/SciSharp/) | |
| 142 | 146 | <br> | |
| 143 | - <a href="http://scisharpstack.org"><img src="https://github.com/SciSharp/SciSharp/blob/master/art/scisharp-stack.png" width="391" height="100" /></a> | ||
| 147 | + <a href="http://scisharpstack.org"><img src="https://github.com/SciSharp/SciSharp/blob/master/art/scisharp-stack.png" width="391" height="100" /></a> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ public class MemoryMonitor | |||
| 10 | 10 | { | |
| 11 | 11 | public void WarmUp() | |
| 12 | 12 | { | |
| 13 | - print(tf.VERSION); | ||
| 13 | + print($"tensorflow native version: v{tf.VERSION}"); | ||
| 14 | 14 | } | |
| 15 | 15 | ||
| 16 | 16 | public void Execute(int epoch, int iterate, Action<int> process) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | </PropertyGroup> | |
| 9 | 9 | ||
| 10 | 10 | <ItemGroup> | |
| 11 | - <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.2.0.2" /> | ||
| 11 | + <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.3.0" /> | ||
| 12 | 12 | </ItemGroup> | |
| 13 | 13 | ||
| 14 | 14 | <ItemGroup> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,5 +26,8 @@ public class CompatApi | |||
| 26 | 26 | { | |
| 27 | 27 | public CompatV1Api v1 { get; } = new CompatV1Api(); | |
| 28 | 28 | } | |
| 29 | + | ||
| 30 | + public bool executing_eagerly() | ||
| 31 | + => Context.executing_eagerly(); | ||
| 29 | 32 | } | |
| 30 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,17 +16,15 @@ limitations under the License. | |||
| 16 | 16 | ||
| 17 | 17 | using System; | |
| 18 | 18 | using System.Collections.Generic; | |
| 19 | - using Tensorflow.Eager; | ||
| 19 | + using Tensorflow.Contexts; | ||
| 20 | 20 | using static Tensorflow.Binding; | |
| 21 | 21 | ||
| 22 | 22 | namespace Tensorflow | |
| 23 | 23 | { | |
| 24 | 24 | public class CompatV1Api | |
| 25 | 25 | { | |
| 26 | 26 | public void disable_eager_execution() | |
| 27 | - { | ||
| 28 | - tf.context.default_execution_mode = Context.GRAPH_MODE; | ||
| 29 | - } | ||
| 27 | + => tf.Context.graph_mode(); | ||
| 30 | 28 | ||
| 31 | 29 | public IVariableV1 get_variable(string name, | |
| 32 | 30 | TensorShape shape = null, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ limitations under the License. | |||
| 18 | 18 | using System.Collections.Generic; | |
| 19 | 19 | using System.Linq; | |
| 20 | 20 | using NumSharp; | |
| 21 | + using Tensorflow.Keras; | ||
| 21 | 22 | using Tensorflow.Keras.ArgsDefinition; | |
| 22 | 23 | using Tensorflow.Keras.Layers; | |
| 23 | 24 | using Tensorflow.Operations.Activation; | |
@@ -164,7 +165,7 @@ public Tensor max_pooling2d(Tensor inputs, | |||
| 164 | 165 | /// <returns></returns> | |
| 165 | 166 | public Tensor dense(Tensor inputs, | |
| 166 | 167 | int units, | |
| 167 | - IActivation activation = null, | ||
| 168 | + Activation activation = null, | ||
| 168 | 169 | bool use_bias = true, | |
| 169 | 170 | IInitializer kernel_initializer = null, | |
| 170 | 171 | IInitializer bias_initializer = null, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,90 @@ | |||
| 1 | + /***************************************************************************** | ||
| 2 | + Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. | ||
| 3 | + | ||
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + you may not use this file except in compliance with the License. | ||
| 6 | + You may obtain a copy of the License at | ||
| 7 | + | ||
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + | ||
| 10 | + Unless required by applicable law or agreed to in writing, software | ||
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + See the License for the specific language governing permissions and | ||
| 14 | + limitations under the License. | ||
| 15 | + ******************************************************************************/ | ||
| 16 | + | ||
| 17 | + using System; | ||
| 18 | + using Tensorflow.Eager; | ||
| 19 | + | ||
| 20 | + namespace Tensorflow.Contexts | ||
| 21 | + { | ||
| 22 | + /// <summary> | ||
| 23 | + /// Environment in which eager operations execute. | ||
| 24 | + /// </summary> | ||
| 25 | + public sealed class Context : IDisposable | ||
| 26 | + { | ||
| 27 | + public const int GRAPH_MODE = 0; | ||
| 28 | + public const int EAGER_MODE = 1; | ||
| 29 | + | ||
| 30 | + int defaultExecutionMode = EAGER_MODE; | ||
| 31 | + public string DeviceName { get; set; } = ""; | ||
| 32 | + public string ScopeName { get; set; } = ""; | ||
| 33 | + bool initialized = false; | ||
| 34 | + bool isEager; | ||
| 35 | + ContextSwitchStack contextSwitches; | ||
| 36 | + | ||
| 37 | + public SafeContextHandle Handle { get; } | ||
| 38 | + | ||
| 39 | + public Context(ContextOptions opts, Status status) | ||
| 40 | + { | ||
| 41 | + Handle = c_api.TFE_NewContext(opts.Handle, status.Handle); | ||
| 42 | + status.Check(true); | ||
| 43 | + isEager = defaultExecutionMode == EAGER_MODE; | ||
| 44 | + contextSwitches = new ContextSwitchStack(isEager); | ||
| 45 | + initialized = true; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /// <summary> | ||
| 49 | + /// Initialize handle and devices if not already done so. | ||
| 50 | + /// </summary> | ||
| 51 | + public void ensure_initialized() | ||
| 52 | + { | ||
| 53 | + if (initialized) | ||
| 54 | + return; | ||
| 55 | + initialized = true; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void start_step() | ||
| 59 | + => c_api.TFE_ContextStartStep(Handle); | ||
| 60 | + | ||
| 61 | + public void end_step() | ||
| 62 | + => c_api.TFE_ContextEndStep(Handle); | ||
| 63 | + | ||
| 64 | + /// <summary> | ||
| 65 | + /// Checks whether the current thread has eager execution enabled. | ||
| 66 | + /// </summary> | ||
| 67 | + /// <returns></returns> | ||
| 68 | + public bool executing_eagerly() | ||
| 69 | + => isEager; | ||
| 70 | + | ||
| 71 | + public string shared_name(string name = null) | ||
| 72 | + => !string.IsNullOrEmpty(name) || !executing_eagerly() ? | ||
| 73 | + name : | ||
| 74 | + "cd2c89b7-88b7-44c8-ad83-06c2a9158347"; | ||
| 75 | + | ||
| 76 | + public void graph_mode() | ||
| 77 | + => mode(false); | ||
| 78 | + | ||
| 79 | + public void eager_mode() | ||
| 80 | + => mode(true); | ||
| 81 | + | ||
| 82 | + void mode(bool mode) | ||
| 83 | + { | ||
| 84 | + isEager = mode; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void Dispose() | ||
| 88 | + => Handle.Dispose(); | ||
| 89 | + } | ||
| 90 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,8 +15,9 @@ limitations under the License. | |||
| 15 | 15 | ******************************************************************************/ | |
| 16 | 16 | ||
| 17 | 17 | using System; | |
| 18 | + using Tensorflow.Eager; | ||
| 18 | 19 | ||
| 19 | - namespace Tensorflow.Eager | ||
| 20 | + namespace Tensorflow.Contexts | ||
| 20 | 21 | { | |
| 21 | 22 | public sealed class ContextOptions : IDisposable | |
| 22 | 23 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments