I use tf2.1 train the model,but it happens the error

Traceback (most recent call last):
File “D:/Learning/professional knowledge/DeepLearning-DGL/TensorFlow/DGI/train.py”, line 171, in
main()
File “D:/Learning/professional knowledge/DeepLearning-DGL/TensorFlow/DGI/train.py”, line 69, in main
loss = dgi(features)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py”, line 822, in call
outputs = self.call(cast_inputs, *args, **kwargs)
File “D:\Learning\professional knowledge\DeepLearning-DGL\TensorFlow\DGI\dgi.py”, line 54, in call
positive = self.encoder(features, corrupt=False)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py”, line 822, in call
outputs = self.call(cast_inputs, *args, **kwargs)
File “D:\Learning\professional knowledge\DeepLearning-DGL\TensorFlow\DGI\dgi.py”, line 27, in call
features = self.conv(features)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py”, line 822, in call
outputs = self.call(cast_inputs, *args, **kwargs)
File “D:\Learning\professional knowledge\DeepLearning-DGL\TensorFlow\DGI\gcn.py”, line 36, in call
h = layer(self.g, h)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py”, line 822, in call
outputs = self.call(cast_inputs, *args, **kwargs)
File “D:\Installer-software\ANACONDA\lib\site-packages\dgl\nn\tensorflow\conv\graphconv.py”, line 109, in call
in_degree = tf.clip_by_value(tf.cast(graph.in_degrees(), tf.float32), clip_value_min=1,
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\util\dispatch.py”, line 180, in wrapper
return target(*args, **kwargs)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\ops\math_ops.py”, line 705, in cast
x = ops.convert_to_tensor(x, name=“x”)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\framework\ops.py”, line 1314, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\framework\constant_op.py”, line 317, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\framework\constant_op.py”, line 258, in constant
allow_broadcast=True)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\framework\constant_op.py”, line 266, in _constant_impl
t = convert_to_eager_tensor(value, ctx, dtype)
File “D:\Installer-software\ANACONDA\lib\site-packages\tensorflow_core\python\framework\constant_op.py”, line 96, in convert_to_eager_tensor
return ops.EagerTensor(value, ctx.device_name, dtype)
ValueError: Attempt to convert a value (tensor([1, 5, 1, …, 3, 1, 1])) with an unsupported type (<class ‘torch.Tensor’>) to a Tensor.

Hi,

Sorry for the inconvenience. However our Tensorflow on DGL currently doesn’t support Windows. (Due to a plugin called tfdlpack doesn’t support on Windows). You could try linux environment with Docker/WSL on Windows, or trying our Pytorch support on DGL. More information can be found at https://docs.dgl.ai/install/backend.html

Here are your options to work around this issue:

  1. Using Linux Environment with Docker/WSL on Windows:
  • Docker: Docker allows you to create a containerized Linux environment on your Windows machine. You can install TensorFlow and DGL within this Linux-based Docker container, which should bypass the compatibility issue with Windows. Docker can be a bit resource-intensive, so make sure your system meets the hardware requirements.
  • Windows Subsystem for Linux (WSL): WSL lets you run a Linux environment directly on Windows, without the overhead of a virtual machine. You can install TensorFlow and DGL in this Linux subsystem. WSL2, the latest version, offers better performance and compatibility compared to WSL1.
  1. Switching to PyTorch with DGL:
  • If you prefer to stay within the Windows environment without using Docker or WSL, another option is to switch from TensorFlow to PyTorch. DGL supports PyTorch on Windows, so this switch might be a simpler solution if it aligns with your project requirements.
  1. Using a Virtual Machine:
  • As an alternative to Docker or WSL, you could set up a Linux virtual machine (VM) using software like VirtualBox or VMware. This allows you to run a full Linux operating system on your Windows machine, where you can install TensorFlow and DGL. Keep in mind that running a VM can be resource-intensive and might have performance overhead.
  1. Using a Cloud-based Platform:
  • Consider using cloud-based platforms like Google Colab, AWS, or Azure, which can provide you with a Linux environment. These platforms often come with TensorFlow and other machine learning libraries pre-installed and can be a quick way to get up and running without local installation hassles.