卷积函数-conv2d

import tensorflow as tf
import numpy as np


input_data = tf.Variable( np.random.rand(10, 9, 9 ,3), dtype = np.float32 )
filter_data = tf.Variable( np.random.rand(2, 2, 3, 2), dtype = np.float32)
y = tf.nn.conv2d(input_data, filter_data, strides = [1, 1, 1, 1], padding = 'SAME')

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print sess.run(y)
    print sess.run(tf.shape(y))




[[[[ 2.28441477  3.06847477]
   [ 2.86936951  3.36118436]
   [ 2.90876746  3.83813024]
   ...,
   [ 1.63569283  2.06621099]
   [ 2.24114609  3.10374069]
   [ 1.23497581  1.39789116]]


  [[ 2.01059985  2.70281553]
   [ 2.31235123  2.97695923]
   [ 2.71346474  2.56986856]
   ...,
   [ 1.97958255  2.39565802]
   [ 1.52550602  2.40602493]
   [ 1.44903207  0.7784394 ]]


  [[ 2.93185854  2.95032263]
   [ 1.82584941  2.5140605 ]
   [ 2.92788196  3.14288759]
   ...,
   [ 2.48327637  3.02099347]
   [ 2.35544467  2.80534363]
   [ 0.96245033  0.80687135]]


  ...,
  [[ 2.78728533  3.08616018]
   [ 2.81141281  3.79395676]
   [ 2.73261857  2.61715674]
   ...,
   [ 2.75830841  3.11794996]
   [ 2.61598086  2.74874234]
   [ 0.9380343   0.91474104]]


  [[ 2.01401186  2.82440901]
   [ 3.01286578  3.90122676]
   [ 3.22464895  3.72051382]
   ...,
   [ 1.95198154  2.38326359]
   [ 2.19041157  2.90743423]
   [ 1.71184278  0.91215426]]


  [[ 0.69879651  1.29733109]
   [ 1.66762972  1.41474044]
   [ 1.3976984   2.02703118]
   ...,
   [ 1.0184195   0.74748439]
   [ 0.82535017  0.90885115]
   [ 0.8296777   0.61198354]]]




 [[[ 3.00285864  3.66854453]
   [ 2.17865944  3.95667744]
   [ 3.32269382  3.90519333]
   ...,
   [ 1.75325131  3.03243518]
   [ 1.56798875  2.7367065 ]
   [ 1.06911421  0.64623517]]


  [[ 3.87107611  4.34347582]
   [ 2.23594332  3.65853691]
   [ 2.44312477  3.2281127 ]
   ...,
   [ 2.77767992  2.86911583]
   [ 2.37514257  2.77617216]
   [ 1.10845053  0.97984314]]


  [[ 2.17275143  3.11631107]
   [ 2.43488026  2.70688319]
   [ 2.20407176  2.63178682]
   ...,
   [ 2.49707651  2.8172946 ]
   [ 2.74680591  3.23685098]
   [ 1.72101617  1.719607  ]]


  ...,
  [[ 2.876616    3.53369856]
   [ 2.5170207   3.24979591]
   [ 2.33437181  2.35978389]
   ...,
   [ 3.04654884  4.5875473 ]
   [ 3.86541176  4.33993578]
   [ 1.66550374  1.12523925]]


  [[ 2.58393836  3.94380355]
   [ 3.24331427  3.53925443]
   [ 3.06660414  2.72423649]
   ...,
   [ 3.28876805  4.26353025]
   [ 2.73433876  3.29844904]
   [ 1.35066676  0.89224339]]


  [[ 1.31961608  2.05621338]
   [ 1.57045865  1.73030257]
   [ 1.38873529  1.23816729]
   ...,
   [ 1.94063663  2.15966296]
   [ 0.89746934  1.36882854]
   [ 0.54245079  0.14804356]]]




 [[[ 2.35181999  2.92467499]
   [ 3.41341424  3.52672577]
   [ 2.47169447  3.50138426]
   ...,
   [ 1.36647558  2.8227663 ]
   [ 2.13923836  2.57541609]
   [ 0.57179981  1.19623995]]


  [[ 2.94395542  4.073771  ]
   [ 3.0283916   3.84947634]
   [ 3.35602498  4.05159855]
   ...,
   [ 2.15090227  3.11249089]
   [ 2.2351923   2.56126785]
   [ 1.36848688  0.72942787]]


  [[ 3.27091742  4.36461735]
   [ 2.64745045  2.80718303]
   [ 2.3807416   3.63565207]
   ...,
   [ 2.19285297  2.68066025]
   [ 2.62513781  2.92402267]
   [ 1.10025692  1.16136837]]


  ...,
  [[ 3.01076126  3.4119482 ]
   [ 1.85087693  3.22764778]
   [ 2.76176405  2.91168904]
   ...,
   [ 2.55947065  3.47643113]
   [ 2.65126657  3.58177614]
   [ 1.59869909  1.23286581]]


  [[ 2.59230924  3.38325787]
   [ 2.22486281  2.48523927]
   [ 1.72652149  2.69701433]
   ...,
   [ 2.23065948  2.60219693]
   [ 2.36404562  3.73067355]
   [ 1.77414346  1.37843394]]


  [[ 0.97523886  1.13877046]
   [ 1.45419931  0.98639047]
   [ 0.75436819  0.8086229 ]
   ...,
   [ 0.93567371  1.45672941]
   [ 1.35910726  1.7025404 ]
   [ 1.2021718   0.9415859 ]]]




 ...,
 [[[ 2.46098757  3.22544956]
   [ 2.47662306  3.55110836]
   [ 2.4317894   2.48825502]
   ...,
   [ 2.17777824  2.89912939]
   [ 3.05267835  3.78674769]
   [ 1.83052111  1.28529596]]


  [[ 2.10993528  2.68119574]
   [ 2.99710703  3.28453517]
   [ 2.70201182  3.97987652]
   ...,
   [ 1.7376579   1.41152024]
   [ 2.55227089  3.20672607]
   [ 1.97965407  1.46010005]]


  [[ 2.19772291  2.62603664]
   [ 2.60253549  2.83817363]
   [ 2.25216103  3.78826547]
   ...,
   [ 1.45738602  2.01276708]
   [ 2.51962566  2.96650028]
   [ 1.43600976  1.2179904 ]]


  ...,
  [[ 1.93896747  3.25516057]
   [ 2.49237108  2.79077721]
   [ 2.79178309  2.67786503]
   ...,
   [ 2.65839028  1.96878338]
   [ 2.11396408  2.84220266]
   [ 0.94130039  1.41221488]]


  [[ 2.20868111  1.97231257]
   [ 1.83280671  2.05507207]
   [ 2.29310036  3.86106825]
   ...,
   [ 2.73892999  3.28985763]
   [ 2.72056603  2.56073999]
   [ 0.84322411  1.36854875]]


  [[ 1.21004152  1.46410084]
   [ 1.04700136  0.97574151]
   [ 1.16823506  2.28405547]
   ...,
   [ 1.72344029  1.56731033]
   [ 1.42622149  1.47656095]
   [ 0.67297661  0.17105176]]]




 [[[ 2.1493187   2.83201408]
   [ 2.40550518  3.64812636]
   [ 3.01165819  3.45196104]
   ...,
   [ 3.18396378  4.28989172]
   [ 3.0395472   3.2183466 ]
   [ 1.02563179  1.2394067 ]]


  [[ 2.56986713  3.39787626]
   [ 3.14118719  3.60724711]
   [ 2.42699313  3.05054379]
   ...,
   [ 3.02555251  3.84614849]
   [ 2.5915637   3.60050106]
   [ 1.08133292  0.9801904 ]]


  [[ 2.7895484   3.26012802]
   [ 2.68198657  3.03690243]
   [ 1.55666649  2.69858265]
   ...,
   [ 2.37659574  2.86296129]
   [ 2.12536287  3.17281008]
   [ 1.06695342  0.90059114]]


  ...,
  [[ 2.559901    3.9107275 ]
   [ 2.4477582   3.25638652]
   [ 2.41677403  2.12277007]
   ...,
   [ 2.21316862  3.35137677]
   [ 2.10929203  2.41750932]
   [ 0.56258953  0.76881254]]


  [[ 3.8143177   4.02317667]
   [ 1.98848999  2.80659127]
   [ 2.05915785  3.13008142]
   ...,
   [ 2.07863283  3.25673485]
   [ 2.28678918  3.44819236]
   [ 0.9778313   1.25186169]]


  [[ 2.16899443  1.81443906]
   [ 1.1907239   1.3821789 ]
   [ 1.15051484  1.89745927]
   ...,
   [ 1.17642415  1.05422068]
   [ 1.17066789  1.91201067]
   [ 0.6694082   0.69027495]]]




 [[[ 2.33095121  3.84507108]
   [ 3.19045091  3.5068593 ]
   [ 3.05367851  3.88874531]
   ...,
   [ 3.08059406  3.65819788]
   [ 2.46952462  2.62755013]
   [ 0.56767726  0.56772256]]


  [[ 2.63759875  3.17783689]
   [ 3.31892586  3.78526974]
   [ 3.32958961  4.31831121]
   ...,
   [ 2.47733831  3.25966549]
   [ 3.15235138  2.89481115]
   [ 0.9032011   0.98115283]]


  [[ 1.84606934  2.23636961]
   [ 2.82043672  3.00273299]
   [ 3.02201033  3.40184736]
   ...,
   [ 2.59918952  3.28301144]
   [ 3.64022636  4.21657276]
   [ 1.75729036  1.51518643]]


  ...,
  [[ 2.35361028  2.86604118]
   [ 1.91406894  2.41733742]
   [ 2.22170973  3.23638821]
   ...,
   [ 2.36277723  3.06239462]
   [ 1.57983088  1.56720269]
   [ 0.73788458  0.78195465]]


  [[ 2.50267982  3.19840217]
   [ 1.86310196  2.16363358]
   [ 2.35080171  2.87520361]
   ...,
   [ 3.0470252   3.58498788]
   [ 2.39537287  2.6719594 ]
   [ 1.14137316  1.12938166]]


  [[ 1.32827282  1.30217993]
   [ 0.70091486  0.56333184]
   [ 0.78078008  1.46257758]
   ...,
   [ 1.97750568  1.89606833]
   [ 1.58064485  1.86012006]
   [ 1.2703805   0.57370603]]]]
[10  9  9  2]

你可能感兴趣的:(TFBoy)