Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
51535c94
Commit
51535c94
authored
Jul 04, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add softmax
parent
aec8cd3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
tensorpack/models/softmax.py
tensorpack/models/softmax.py
+21
-0
tensorpack/utils/utils.py
tensorpack/utils/utils.py
+1
-1
No files found.
tensorpack/models/softmax.py
0 → 100644
View file @
51535c94
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: softmax.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
tensorflow
as
tf
from
._common
import
layer_register
__all__
=
[
'SoftMax'
]
@
layer_register
()
def
SoftMax
(
x
,
use_temperature
=
False
,
temperature_init
=
1.0
):
"""
A SoftMax layer (no linear projection) with optional temperature
:param x: a 2D tensor
"""
if
use_temperature
:
t
=
tf
.
get_variable
(
'temp'
,
[
1
],
initializer
=
tf
.
constant_initializer
(
1.0
/
float
(
temperature_init
)))
x
=
x
*
t
return
tf
.
nn
.
softmax
(
x
,
name
=
'output'
)
tensorpack/utils/utils.py
View file @
51535c94
...
@@ -89,7 +89,7 @@ def get_gpus():
...
@@ -89,7 +89,7 @@ def get_gpus():
def
get_dataset_dir
(
name
):
def
get_dataset_dir
(
name
):
d
=
os
.
environ
.
get
(
'TENSORPACK_DATASET'
,
None
)
d
=
os
.
environ
.
get
(
'TENSORPACK_DATASET'
,
None
)
if
d
:
if
d
:
assert
os
.
path
.
isdir
(
d
)
assert
os
.
path
.
isdir
(
d
)
,
d
else
:
else
:
d
=
os
.
path
.
abspath
(
os
.
path
.
join
(
d
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'dataflow'
,
'dataset'
))
os
.
path
.
dirname
(
__file__
),
'..'
,
'dataflow'
,
'dataset'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment