Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
55 views
in Technique[技术] by (71.8m points)

javascript - Architecture Visualization with Tensorspace - CORS error

I'm trying to visualize my NN architecutre with tensorspace. For this I have created the json file containing the architectural information (model.json in my case).

I tried to now visualize it with JavaScript consisting of the following code however I only get a black screen:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>TensorSpace - LeNet Demo</title>
    <meta name="author" content="syt123450 / https://github.com/syt123450">
    <style>

        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }

        #container {
            width: 100%;
            height: 100%;
            background-color: #000;
        }

    </style>
</head>
<body>

<div id="container"></div>

<script src="../assets/libs/jquery.min.js"></script>
<script src="../assets/libs/three.min.js"></script>
<script src="../assets/libs/tween.min.js"></script>
<script src="../assets/libs/TrackballControls.js"></script>
<script src="../assets/libs/tf.min.js"></script>
<script src="../assets/libs/tensorspace.min.js"></script>

<script>

    let modelContainer = document.getElementById( "container" );

    let model = new TSP.models.Sequential( modelContainer );

//    model.add( new TSP.layers.GreyscaleInput() );

    model.add( new TSP.layers.Conv1d() );

    model.add( new TSP.layers.Conv1d() );

    model.add( new TSP.layers.Pooling1d(); );

    model.add( new TSP.layers.Conv1d() );

    model.add( new TSP.layers.Conv1d() );

    model.add( new TSP.layers.GlobalPooling1d() );

    model.add( new TSP.layers.Dense() );

    model.add(new TSP.layers.Dense());

    model.add( new TSP.layers.Output1d( {

        outputs: [ "0", "1"]

    } ) );

    model.load( {

        type: "keras",
        url: 'model.json'

    } );

    model.init(function() {

        $.ajax( {

            url: "../assets/data/5.json",
            type: 'GET',
            async: true,
            dataType: 'json',
            success: function ( data ) {

                model.predict( data );

            }

        } );

    });

</script>
</body>
</html>

Maybe someone know if I'm doing something wrong.

Edit: I now figured out that it is a CORS error which I'm trying to fix. However I did not find an approrpriate solution yet.

question from:https://stackoverflow.com/questions/65859188/architecture-visualization-with-tensorspace-cors-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...