我已经建立了一个Drake管道,该管道在管道的末尾生成一个报告。我想在每次创建新报告时触发一个松弛通知。对于计划的报告部分,我使用以下内容:
from tensorflow.keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = x_train.reshape(x_train.shape[0], 28*28)
x_test = x_test.reshape(x_test.shape[0], 28*28)
from tensorflow.keras.utils import to_categorical
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
import tensorflow as tf
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense, Activation, Dropout
from tensorflow.keras.optimizers import SGD
def custom_activation(x):
cond = tf.greater(x, tf.constant(0.0))
return tf.where(cond,
x,
tf.subtract(tf.exp(x), tf.constant(1.0)))
model = Sequential([
Dense(128, input_shape=x_train.shape[1:]),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(128),
Activation(custom_activation),
Dense(10),
Activation('sigmoid')
])
model.compile(SGD(lr=0.01), loss='categorical_crossentropy', metrics=['accuracy'])
model.fit(x=x_train, y=y_train,
validation_data=[x_test, y_test],
batch_size=64, epochs=5)
通知目标上的触发器可以工作,但是在我的依赖图中,通知目标只是自身而已:
是否有更好的方法使通知依赖于正在生成的新报告?谢谢!
答案 0 :(得分:2)
这很聪明,我喜欢!触发器中的file_in()
语句怎么办?也许trigger = trigger(change = file.info(file_in("report.html"))$ctime
如果触发得太频繁,也许在源knitr_in()
上有一条trigger = trigger(change = file.info(knitr_in("report.html"))$ctime
语句。我个人更喜欢这些选项中的第二个。
对不起,我很晚才进入这个话题!