2021年3月22日星期一

Tensorflow Graphics - Add DynamicGraph or FeatureSteered Convolution Layer to Keras Model

I am new to TF. I am working with large meshes (num_vertices = 3,000,000). I am trying to align the meshes using the TF graphics 6DOF alignment sample. Preprocessing includes centering the mesh and standardizing the maximum dimensions of the mesh. I am using 2500 samples to train and test the model, which I know is not ideal https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/notebooks/6dof_alignment.ipynb

Experimenting with Conv1D and Pooling layers improved the model but not enough.

TF Graphics has convolutional layers that are supposedly be better suited for working with meshes. I tried to implement using a second tutorial but I've been unsuccessful. https://github.com/tensorflow/graphics/blob/test_305236385/tensorflow_graphics/notebooks/mesh_segmentation_demo.ipynb

model = keras.Sequential()  model.add(layers.Conv1D(10, 1, input_shape=(num_vertices,3)))  model.add(layers.Dense(20, activation=tf.nn.relu))  model.add(tf_graph_conv.FeatureSteeredConvolutionKerasLayer())  

the last line gives me an error, regardless of what I select for the input_shape and output_channels parameters.

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/tensor_shape.py in as_list(self)     1188     """     1189     if self._dims is None:  -> 1190       raise ValueError("as_list() is not defined on an unknown TensorShape.")     1191     return [dim.value for dim in self._dims]     1192     ValueError: as_list() is not defined on an unknown TensorShape  

I tried the other layer as well and got a different error:

model.add(tf_graph_conv.DynamicGraphConvolutionKerasLayer(num_output_channels = 20, reduction = 'weighted'))      /usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)      668       except Exception as e:  # pylint:disable=broad-except      669         if hasattr(e, 'ag_error_metadata'):  --> 670           raise e.ag_error_metadata.to_exception(e)      671         else:      672           raise    ValueError: in user code:        /usr/local/lib/python3.7/dist-packages/tensorflow_graphics/nn/layer/graph_convolution.py:427 call  *          data=inputs[0],      /usr/local/lib/python3.7/dist-packages/tensorflow_graphics/geometry/convolution/graph_convolution.py:247 edge_convolution_template  *          utils.check_valid_graph_convolution_input(data, neighbors, sizes)      /usr/local/lib/python3.7/dist-packages/tensorflow_graphics/geometry/convolution/utils.py:62 check_valid_graph_convolution_input  *          raise ValueError("'neighbors' must be a SparseTensor.")        ValueError: 'neighbors' must be a SparseTensor.  

'neighbors' is a sparse tensor and can be generated using get_weighted_edges() and adjacency_from_edges(). However, I haven't found a way to pass in this variable manually. https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/notebooks/mesh_segmentation_dataio.py

Please help!!

https://stackoverflow.com/questions/66758042/tensorflow-graphics-add-dynamicgraph-or-featuresteered-convolution-layer-to-ke March 23, 2021 at 02:05PM

没有评论:

发表评论