Skip to content

Commit

Permalink
feat: add linear modal
Browse files Browse the repository at this point in the history
  • Loading branch information
chaxus committed Nov 6, 2023
1 parent dc9837a commit 2465c30
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/ml/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ const createModal = () => {
const model = tf.sequential()

model.add(tf.layers.dense({
units: 1,
units: 4,
useBias: true,
activation: 'linear',
inputDim: 1
}))

const optimizer = tf.train.sgd(0.1)
model.compile({
loss: "meanSquaredError",
optimizer
})
return model
}
const tfTensor = async () => {
Expand Down Expand Up @@ -88,10 +94,13 @@ const tfTensor = async () => {
// 分割测试集和训练集
const [trainingFeatureTensor, testingFeatureTensor] = tf.split(normaliseFeatureTensor.tensor, 2)
const [trainingLabelTensor, testingLabelTensor] = tf.split(normaliseLabelTensor.tensor, 2)
// 创建模型
// 创建模型
const modal = createModal()
modal.summary()
tfvis.show.modelSummary({ name: "Modal summary" }, modal)
// 了解 layer
const layer = modal.getLayer(undefined, 0)
tfvis.show.layer({ name: "Layer 1" }, layer)
}

const App = () => {
Expand Down

0 comments on commit 2465c30

Please sign in to comment.