我正在尝试设置从tf.py_function调用返回的numpy数组的形状。函数返回数组的元组和它的形状,所以我可以在tf.function中设置它的形状。我尝试将其强制转换为int32或通过索引等方式访问它,但都会导致TypeError: Dimension value must be integer or None or have an __index__ method, got value '<tf.Tensor 'strided_slice:0' shape=<unknown> dty
虽然我想在tensorflow_datasets中将张量转换为numpy数组,但我的代码逐渐变慢了。现在,我使用包含300多万张图像的lsun/卧室数据集。如何加速我的代码?我的代码保存tuple,它每100,000张图像有一个numpy数组。train_tf["train"] if d_cnt==0 and d_cnt%100001==0:
train = (tfds.as_num
inputs["token_type_ids"], inputs["attention_mask"] 我想通过这样做来动态地对我的数据进行编码: x_train = (tf.data.Dataset.from_tensor_slicesShould be a string, a list/tuple of strings or a list/tuple of integers.现在,根据我的理解,当我在encode中设置断点时,是因为我发送了一个非numpy数组。
maxMinDiffLossConstrained(y_true, y_pred, sample_weight=None): y_pred_shape = list(y_pred.shape) # y_pred returns a tuple, we want a list so we can construct another tensor