Chapter13: Exercise 10-d. tf.RaggedTensor.to_tensor() have no Argument "shape" in tf2.0 version
- Lingua principale
- Jupyter Notebook
- Stelle
- 30k
- Fork
- 13.1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In the Cell142:
```python
def preprocess(X_batch, n_words=50):
shape = tf.shape(X_batch) * tf.constant([1, 0]) + tf.constant([0, n_words])
Z = tf.strings.substr(X_batch, 0, 300)
Z = tf.strings.lower(Z)
Z = tf.strings.regex_replace(Z, b"", b" ")
Z = tf.strings.regex_replace(Z, b"[^a-z]", b" ")
Z = tf.strings.split(Z)
return Z.to_tensor(shape=shape, default_value=b"")
X_example = tf.constant(["It's a great, great movie! I loved it.", "It was terrible, run away!!!"])
preprocess(X_example)
```
I can't run it with tf2.0 , so I want create a empty matrix use `tmp = tf.fill(dims=shape, b'')` and then convert `tmp` to `tf.Variable` ,use `assign` function for assignment finally. But when I test this `tmp[0,0].assign(2)` , there is some error like this:
`Cannot convert 2 to EagerTensor of dtype string`
So how to change its shape. THANK U
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.