Dynamic mode decomposition (DMD) is a powerful data-driven technique for construction of reduced-order models of complex dynamical systems. Multiple numerical tests have demonstrated the accuracy and efficiency of DMD, but mostly for systems described by homogeneous partial differential equations (PDEs) with homogeneous boundary conditions. We propose an extended dynamic mode decomposition (xDMD) approach to cope with the potential unknown sources/sinks in PDEs. Motivated by similar ideas in deep neural networks, we equip our xDMD with two new features. First, it has a bias term, which accounts for inhomogeneity of PDEs and/or boundary conditions. Second, instead of learning a flow map, xDMD learns the residual increment by subtracting the identity operator. Our theoretical error analysis demonstrates the improved accuracy of xDMD relative to standard DMD. Several numerical examples are presented to illustrate this result.