我正在尝试制作可以重复几次(或无限次)的简单动画.
好像android:repeatCount不行!
这是我的动画资源/res/anim/first_animation.xml:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:repeatCount="infinite"
>
<scale
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="1.2"
android:toYScale="1.2"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false" />
<scale
android:interpolator="@android:anim/accelerate_interpolator"
android:startOffset="500"
android:duration="500"
android:fromXScale="1.2"
android:fromYScale="1.2"
android:toXScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false" />
</set>
Run Code Online (Sandbox Code Playgroud)
首先,它应该在500毫秒内将图像从1.0尺寸缩放到1.2尺寸.
然后在500毫秒内将其缩放回1.0.
这是我如何使用它:
Animation firstAnimation = AnimationUtils.loadAnimation(this, R.anim.first_animation);
imgView.startAnimation(firstAnimation);
Run Code Online (Sandbox Code Playgroud)
它进行一个循环然后结束.
它会向上扩展,然后向下缩小然后停止.
我该如何按预期工作?
我需要使用tf.keras.*. 但:
(num_classes - 1)相反。我想利用tf.nn.ctc_loss其中有一些很好的论点:blank_index。所以我做了一个简单的包装器来计算 CTC 损失:
class CTCLossWrapper(tf.keras.losses.Loss):
def __init__(self, blank_class: int, reduction: str = tf.keras.losses.Reduction.AUTO, name: str = 'ctc_loss'):
super().__init__(reduction=reduction, name=name)
self.blank_class = blank_class
def call(self, y_true, y_pred):
output = y_true['output']
targets, target_lenghts = output['targets'], output['target_lengths']
y_pred = tf.math.log(tf.transpose(y_pred, perm=[1, 0, 2]) + K.epsilon())
max_input_len = K.cast(K.shape(y_pred)[1], dtype='int32')
input_lengths = tf.ones((K.shape(y_pred)[0]), dtype='int32') * max_input_len
return tf.nn.ctc_loss(
labels=targets,
logits=y_pred,
label_length=target_lenghts,
logit_length=input_lengths,
blank_index=self.blank_class
)
Run Code Online (Sandbox Code Playgroud)
我还编写了一个简单的生成器函数,它生成训练样本:
def generator(dataset, batch_size: …Run Code Online (Sandbox Code Playgroud)