From 9d9c88e7a52eac692aefe9cb20e3965adf1c8029 Mon Sep 17 00:00:00 2001 From: vshakhlin Date: Fri, 3 Dec 2021 18:05:19 +0000 Subject: [PATCH] Check if callContext is null or callContext.Value is null create a new ThreadLocal with CallContext. --- src/TensorFlowNET.Keras/Engine/Layer.Apply.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TensorFlowNET.Keras/Engine/Layer.Apply.cs b/src/TensorFlowNET.Keras/Engine/Layer.Apply.cs index b19d5307..cabd56cd 100644 --- a/src/TensorFlowNET.Keras/Engine/Layer.Apply.cs +++ b/src/TensorFlowNET.Keras/Engine/Layer.Apply.cs @@ -14,7 +14,7 @@ namespace Tensorflow.Keras.Engine /// public Tensors Apply(Tensors inputs, Tensor state = null, bool training = false) { - callContext = callContext ?? new ThreadLocal() + callContext = callContext?.Value != null ? callContext : new ThreadLocal() { Value = new CallContext() };