#!/usr/bin/env python# -*- coding: utf-8 -*-import tensorflow as tf x = tf.constant(2)y = tf.constant(20)z = tf.Variable([[6,1,2],[3,4,5],[0,0,0],[8,2,4]])mask=z[:,0]>0res = tf.boolean_mask(z,mask)init_assign = tf.global_variables_initializer()with t…