.NET based ecosystem of open-source software for mathematics, science, and engineering.
dependabot[bot] on nuget
Bump Newtonsoft.Json in /src/Te… (compare)
dependabot[bot] on nuget
Bump Newtonsoft.Json from 12.0.… (compare)
dependabot[bot] on nuget
Bump Newtonsoft.Json in /src/IC… (compare)
1 training)
at Tensorflow.Keras.Engine.Layer.<>c__DisplayClass1_0.<Apply>b__0(NameScope scope)
at Tensorflow.Binding.tf_with[T](T py, Action
1 action)@Oceania2018 I'm new to neural networks and tensorflow. I'm not sure what I would unit test.
Would this help?:
1 var_list, Nullable
1 aggregation_method, GateGradientType gate_gradients, Boolean colocate_gradients_with_ops, Tensor grad_loss)1 var_list, GateGradientType gate_gradients, Nullable
1 aggregation_method, Boolean colocate_gradients_with_ops, String name, Tensor grad_loss)
Here's a fun one. Conv2DTranspose has default value for
bool use_bias = true,
However in the actual concrete class:
if (use_bias)
throw new NotImplementedException("");
case int[] shape2:
if (shape.ndim != shape2.Length)
return false;
int[] newDims;
newDims = new int[shape.dims.Length];
for (int i = 0; i < shape.dims.Length; i++)
{
newDims[i] = (int)shape.dims[i];
}
return Enumerable.SequenceEqual(newDims, shape2);
@Craigjw @SuperDaveOsbourne @AndreasHogstrandUltromics_gitlab Sadly after over an year of banging my head on the wall I've finally given up and moved across to using TorchSharp. Unfortunately for non trivial models there is some kind of a bug in the C++ build of Tensorflow itself. Which is not there in the Python Version.
What I've found is that regardless of which version you use and I have tried TF1.3, TF 1.15.5, TF 2.3, TF 2.6 The C++ build of Tensorflow has some kind of weird bug in it. I've tried both the nuget packaged versions provided here. As well as compiling from source using bazel. It makes no difference. The bug is "silent corruption of data". What this means is when building non trivial models (More complex than the samples or the unit tests) or in other words deep networks of more than 2 or 3 layers your model will train upto a certain point. After which it will not train anymore. You can try with Adam, ADAGrad, RMSProp or whatever you want. Your model will not train beyond a certain level. From what I can see it is related to floating point precision of the weight updates from gradients.
@Craigjw May I suggest just building it all in a console app. Much easier and a lot less pain. Also don't bother with the Eager mode if your planning on using GPU. Actually don't bother either way. Which unfortunately means that all of Keras is out the window. Here is the reason. When running in eager mode you have to use Gradient Tape. While the Python version of Gradient Tape might be computationally efficient, the Dot net translated version is anything But. Since most of this framework is tested on CPU rather than GPU this issue is hidden and not that obvious. However if your planning on doing any real training you will need to use GPU and lemme put it this way. I'm running a threadripper with 4 X 3090 cards. The Gradient Tape implementation is single threaded and I can barely manage to get one GPU at just over 2% Cuda utilization.
Your alternative is to use Graph mode which does work quite well. This however means Tensorflow Native which is really not that much of a big deal. Most of the operations are fully implemented except in the area of convolutions. Conv2D is implemented and does work. However Conv2dTranspose is not implemented to any functional level. Having said that its also not that much of a big deal cause you can get close to the same result using dilated conv2D followed by a standard dense to expand the shape. I've tested this approach and it does work decently.
@AndreasHogstrandUltromics_gitlab May I suggest using NetMQ for your transport along with MessagePack and MessagePack.Annotations for serialization. I can get near wire speed (1Gbps) serialization of floats from multiple agents to the central Neural Network (Multi Agent reinforcement learning scenario). Note: the Numpy implementation in Tensorflow.Net is extremely performant and blazing fast for converting float shape structures. Much faster than the methods used in TorshSharp so I'm continuing to use the Numpy implementation even through I'm now using TorchSharp as the neural network backend
public static Tensor FullyConnectedDense(Tensor _Input, int _Num_Units, TF_DataType dataType = TF_DataType.TF_FLOAT, bool Trainable = true, bool Normalize = false,
IInitializer InitializeVariant = null, string _Name = null)
{
if (InitializeVariant == null)
{
InitializeVariant = tf.truncated_normal_initializer(0, 1);
}
int in_dim = (int)_Input.shape[1];
string WeightsName;
string BiasName;
WeightsName = _Name.ConcatIfNotNullOrEmptyElseNull(@"_Weights");
BiasName = _Name.ConcatIfNotNullOrEmptyElseNull(@"_Bias");
if (in_dim == 0)
{
in_dim = -1;
}
ResourceVariable Weights;
ResourceVariable Bias;
Weights = tf.Variable(
InitializeVariant,
name: WeightsName,
dtype: dataType,
shape: new int[2] { in_dim, _Num_Units },
trainable: Trainable,
validate_shape: false);
Bias = tf.Variable(
InitializeVariant,
name: BiasName,
dtype: dataType,
shape: new int[1] { _Num_Units },
trainable: Trainable,
validate_shape: false);
Tensor layer = tf.matmul(_Input, Weights) + Bias;
return layer;
}