[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.fixed_size_partitioner\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/partitioned_variables.py#L220-L272) |\n\nPartitioner to specify a fixed number of shards along given axis. \n\n tf.compat.v1.fixed_size_partitioner(\n num_shards, axis=0\n )\n\n\u003cbr /\u003e\n\nMigrate to TF2\n--------------\n\n\u003cbr /\u003e\n\n| **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.\n\nThis API is deprecated in TF2. In TF2, partitioner is no longer part of\nthe variable declaration via [`tf.Variable`](../../../tf/Variable).\n[ParameterServer Training](https://www.tensorflow.org/tutorials/distribute/parameter_server_training)\nhandles partitioning of variables. The corresponding TF2 partitioner class of\n`fixed_size_partitioner` is\n[`tf.distribute.experimental.partitioners.FixedShardsPartitioner`](../../../tf/distribute/experimental/partitioners/FixedShardsPartitioner).\n\nCheck the [migration guide](https://www.tensorflow.org/guide/migrate#2_use_python_objects_to_track_variables_and_losses)\non the differences in treatment of variables and losses between TF1 and TF2.\n\nBefore: \n\n x = tf.compat.v1.get_variable(\n \"x\", shape=(2,), partitioner=tf.compat.v1.fixed_size_partitioner(2)\n )\n\nAfter: \n\n partitioner = (\n tf.distribute.experimental.partitioners.FixedShardsPartitioner(\n num_shards=2)\n )\n strategy = tf.distribute.experimental.ParameterServerStrategy(\n cluster_resolver=cluster_resolver,\n variable_partitioner=partitioner)\n\n with strategy.scope():\n x = tf.Variable([1.0, 2.0])\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|------------------------------------------------|\n| `num_shards` | `int`, number of shards to partition variable. |\n| `axis` | `int`, axis to partition on. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A partition function usable as the `partitioner` argument to `variable_scope` and `get_variable`. ||\n\n\u003cbr /\u003e"]]