我不明白 Keras 函数 "fit"
I don't understand Keras function "fit"
当我构建一个 DataGenerator 并尝试将其放入模型时,它没有用。所以我直接查看了 Keras 函数 'fit'。但我不明白下面的代码是什么意思,尤其是反斜杠符号。请问这个代码是做什么用的,怎么用的?
with self.distribute_strategy.scope(), \
training_utils.RespectCompiledTrainableState(self):
# Creates a `tf.data.Dataset` and handles batch and epoch iteration.
据我所知,“\”只是用于 linebreak
正如@Seitanist 提到的,它只是一个续行。
复制自python docs:
The Python standard library is conservative and requires limiting
lines to 79 characters (and docstrings/comments to 72).
The preferred way of wrapping long lines is by using Python's implied
line continuation inside parentheses, brackets and braces. Long lines
can be broken over multiple lines by wrapping expressions in
parentheses. These should be used in preference to using a backslash
for line continuation.
Backslashes may still be appropriate at times.
For example, long, multiple with-statements cannot use implicit
continuation, so backslashes are acceptable:
with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
当我构建一个 DataGenerator 并尝试将其放入模型时,它没有用。所以我直接查看了 Keras 函数 'fit'。但我不明白下面的代码是什么意思,尤其是反斜杠符号。请问这个代码是做什么用的,怎么用的?
with self.distribute_strategy.scope(), \
training_utils.RespectCompiledTrainableState(self):
# Creates a `tf.data.Dataset` and handles batch and epoch iteration.
据我所知,“\”只是用于 linebreak
正如@Seitanist 提到的,它只是一个续行。
复制自python docs:
The Python standard library is conservative and requires limiting lines to 79 characters (and docstrings/comments to 72).
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
Backslashes may still be appropriate at times. For example, long, multiple with-statements cannot use implicit continuation, so backslashes are acceptable:
with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())