Q:

Print input while training model on every iteration

I want to check what data is in input, or to check output of some layer. For this i do the following:
import tensorflow.keras.backend as K
import tensorflow as tf
import numpy as np

x = [[i, i * 3 + 1] for i in range(100)]
y = [2 * i + 1 for i in range(100)]
x = np.array(x)
y = np.array(y)

print_weights = tf.keras.callbacks.LambdaCallback(
    on_batch_end=lambda batch, logs: print(K.get_value(model.layers[1].input)))

def sobaka():
    a = tf.keras.Input(shape=(2,))
    b = tf.keras.layers.Dense(1)
    c = b(a)
    model = tf.keras.models.Model(a, c)
    optimizer = tf.keras.optimizers.Adam(lr=0.1)
    model.compile(loss='mean_squared_error', optimizer=optimizer, metrics=['accuracy'])
    return model

kek = tf.placeholder(tf.float32, shape=(2,))
model = sobaka()
model.fit(x, y, batch_size=1, epochs=2, callbacks=[print_weights])

So every batch (one training sample) it would print input tensor. But, i got an error:

You must feed a value for placeholder tensor 'input_1' with dtype
  float and shape [?,2]

Please, help me understand how to fit placeholder in my code. And is there any possible solution to print information every iteration? (when batch is ,for example, 10?)

A:

One option is to use a [custom callback][1]
like so:
class MyCallback(tf.keras.callbacks.Callback):

    def __init__(self, patience=0):
        super(MyCallback, self).__init__()

    def on_epoch_begin(self, epoch, logs=None):
        tf.print(self.model.get_weights())

model.fit(
        x_train, 
        y_train, 
        epochs=epochs,
        batch_size=batch_size,
        callbacks=[MyCallback()],
        validation_data=(x_test, y_test),
    )

