Code Monkey home page Code Monkey logo

Comments (5)

owulveryck avatar owulveryck commented on June 17, 2024

Thank you.
It looks good to me, but I am not an expert of this algo (still in the learning phase)
This would explain why I cannot get a “good player” in a reasonable time.

from agogo.

owulveryck avatar owulveryck commented on June 17, 2024

I tried to apply your suggestion (without further investigation), but it fails:

panic: 
Non Differentiable WRTs: 
    map[
       FilterLayer1 of Shared Layer 0 :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%15)_γ :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%15)_β :: Tensor-4 float32:{} 
       FilterLayer1 of Shared Layer 1 :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%32)_γ :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%32)_β :: Tensor-4 float32:{} 
       FilterLayer1 of Shared Layer 2 :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%4f)_γ :: Tensor-4 float32:{} Aᵀ{0, 3, 1, 2}(%4f)_β :: Tensor-4 float32:{}]

from agogo.

Elvenson avatar Elvenson commented on June 17, 2024

Weird it seems to work from my side 😓 Can I take a look at your modification?

from agogo.

owulveryck avatar owulveryck commented on June 17, 2024

I made this patch:

@@ -65,9 +65,9 @@ func (m *maebe) res(input *G.Node, filterCount int, name string) (*G.Node, batch
 }

 func (m *maebe) share(input *G.Node, filterCount, layer int) (*G.Node, batchNormOp, batchNormOp) {
-       layer1, l1Op := m.res(input, filterCount, fmt.Sprintf("Layer1 of Shared Layer %d", layer))
+       _, l1Op := m.res(input, filterCount, fmt.Sprintf("Layer1 of Shared Layer %d", layer))
        layer2, l2Op := m.res(input, filterCount, fmt.Sprintf("Layer2 of Shared Layer %d", layer))
-       added := m.do(func() (*G.Node, error) { return G.Add(layer1, layer2) })
+       added := m.do(func() (*G.Node, error) { return G.Add(input, layer2) })
        retVal := m.rectify(added)
        return retVal, l1Op, l2Op
 }

and the learning function is basically:

func learn() error {
	conf := agogo.Config{
		Name:            "Tic Tac Toe",
		NNConf:          dual.DefaultConf(3, 3, 10),
		MCTSConf:        mcts.DefaultConfig(3),
		UpdateThreshold: 0.52,
	}
	conf.NNConf.BatchSize = 100
	conf.NNConf.Features = 2 // write a better encoding of the board, and increase features (and that allows you to increase K as well)
	conf.NNConf.K = 3
	conf.NNConf.SharedLayers = 3
	conf.MCTSConf = mcts.Config{
		PUCT:           1.0,
		M:              3,
		N:              3,
		Timeout:        50 * time.Millisecond,
		PassPreference: mcts.DontPreferPass,
		Budget:         1000,
		DumbPass:       true,
		RandomCount:    0,
	}

	outEnc := NewEncoder()
	go func(h http.Handler) {
		mux := http.NewServeMux()
		mux.Handle("/ws", h)
		mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./htdocs"))))

		log.Println("go to http://localhost:8080/static")
		http.ListenAndServe(":8080", mux)
	}(outEnc)

	conf.Encoder = encodeBoard
	conf.OutputEncoder = outEnc

	g := mnk.TicTacToe()
	a := agogo.New(g, conf)
	reader := bufio.NewReader(os.Stdin)
	fmt.Print("press ented when ready")
	reader.ReadString('\n')

	//a.Learn(5, 30, 200, 30) // 5 epochs, 50 episode, 100 NN iters, 100 games.
	err := a.Learn(5, 50, 100, 100) // 5 epochs, 50 episode, 100 NN iters, 100 games.
	if err != nil {
		return err
	}
	err = a.Save("example.model")
	if err != nil {
		return err
	}
	return nil
}

from agogo.

Elvenson avatar Elvenson commented on June 17, 2024

I see but I think it should be like this can you help give it a try:

	layer1, l1Op := m.res(input, filterCount, fmt.Sprintf("Layer1 of Shared Layer %d", layer))
	layer2, l2Op := m.res(layer1, filterCount, fmt.Sprintf("Layer2 of Shared Layer %d", layer))

from agogo.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.