Cognitive functions such as learning in mammalian brains have been attributed to the presence of neuronal circuits with feed-forward and feedback topologies. Such networks have interactions within and between neurons that provide excitory and inhibitory modulation effects. In neuromorphic computing, neurons that combine and broadcast both excitory and inhibitory signals using one nanoscale device are still an elusive goal. Here we introduce a type-II, two-dimensional heterojunction-based optomemristive neuron, using a stack of MoS2, WS2 and graphene that demonstrates both of these effects via optoelectronic charge-trapping mechanisms. We show that such neurons provide a nonlinear and rectified integration of information, that can be optically broadcast. Such a neuron has applications in machine learning, particularly in winner-take-all networks. We then apply such networks to simulations to establish unsupervised competitive learning for data partitioning, as well as cooperative learning in solving combinatorial optimization problems.