WordPress:检查第一个古腾堡块是否为H1标题

时间:2019-07-01 22:05:28

标签: php wordpress wordpress-theming wordpress-gutenberg gutenberg-blocks

我想检查第一个Gutenberg块是否为import keras from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import Flatten, Dense, Dropout img_width, img_height = 28, 28 mnist = keras.datasets.mnist (X_train, Y_train), (X_test, Y_test) = mnist.load_data() (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train = keras.utils.normalize(X_train, axis=1) #Normalizes from 0-1 (originally each pixel is valued 0-255) X_test = keras.utils.normalize(X_test, axis=1) #Normalizes from 0-1 (originally each pixel is valued 0-255) Y_train = keras.utils.to_categorical(Y_train) #Reshapes to allow ytrain to work with x train Y_test = keras.utils.to_categorical(Y_test) from sklearn import preprocessing lb = preprocessing.LabelBinarizer() Y_train = lb.fit_transform(Y_train) Y_test = lb.fit_transform(Y_test) #Model model = Sequential() model.add(Flatten()) model.add(Convolution2D(16, 5, 5, activation='relu', input_shape=(1,img_width, img_height, 1))) model.add(Dense(128, activation='relu')) model.add(Dense(128, activation='relu')) model.add(Dropout(.2)) model.add(Dense(64, activation='relu')) model.add(Dense(10, activation='softmax')) model.compile(optimizer = 'adam', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(X_train, Y_train, epochs=3, verbose=2) val_loss, val_acc = model.evaluate(X_test, Y_test) #Check to see if model fits test print(val_loss, val_acc) 标题。 这使我无需更改站点名称即可更改页面标题。

我找到了一种解决方案,可以检查第一个块是否为H1块。 但是我不知道如何检查它是core/heading还是H1

这是我的代码:

H2

来源:https://wordpress.stackexchange.com/a/310318/96806

0 个答案:

没有答案